# Implementation Plan: Agent Tool Preference & Bias Tuning

## Phase 1: Data Model & Storage Extension
- [ ] Task: Extend the `ToolPreset` and `Tool` models.
    - [ ] Update `src/tool_presets.py` (created in the dependency track) to include `weight` (int, 1-5) for tools.
    - [ ] Add `parameter_bias` (dict mapping parameter names to priority strings) to the `Tool` model.
    - [ ] Update `ToolPresetManager` to handle saving and loading these new fields from `tool_presets.toml`.
- [ ] Task: Implement Global Bias Profiles.
    - [ ] Define `BiasProfile` dataclass in `src/models.py`.
    - [ ] Implement logic to store and retrieve these profiles from `config.toml`.
- [ ] Task: Write unit tests for the extended data model and storage logic.
- [ ] Task: Conductor - User Manual Verification 'Phase 1: Data Model Extension' (Protocol in workflow.md)

## Phase 2: Orchestration & Nudging Logic
- [ ] Task: Implement the `ToolBiasEngine` in `src/ai_client.py` (or a new module).
    - [ ] Implement `apply_semantic_nudges(tool_definitions, preset)`: This function should modify tool descriptions with priority tags.
    - [ ] Implement `generate_tooling_strategy(preset, global_bias)`: This function should return a Markdown string for the system prompt.
- [ ] Task: Integrate the bias engine into the AI client `send()` loop.
    - [ ] Ensure that for every agent turn, the tool definitions and system instructions are dynamically biased based on the active agent's role and selected preset.
- [ ] Task: Write integration tests for the bias generation logic.
    - [ ] Verify that high-weight tools correctly receive "[HIGH PRIORITY]" tags.
    - [ ] Verify that the strategy section is correctly appended to the system instructions.
- [ ] Task: Conductor - User Manual Verification 'Phase 2: Orchestration Logic' (Protocol in workflow.md)

## Phase 3: GUI Integration
- [ ] Task: Update the Tool Preset Manager UI.
    - [ ] Add `imgui.slider_int` for each tool to adjust its weight.
    - [ ] Add a sub-menu or modal for editing parameter-level bias.
- [ ] Task: Enhance tool list visualization.
    - [ ] Implement color-coded priority badges in the Operations panel and tool settings.
- [ ] Task: Implement the "Bias Override" in the agent focus modal.
    - [ ] Add a dropdown to select a global bias profile or a specific preset override before spawning a worker.
- [ ] Task: Write visual regression tests using `live_gui` to verify the new UI components.
- [ ] Task: Conductor - User Manual Verification 'Phase 3: GUI Integration' (Protocol in workflow.md)

## Phase 4: Verification & Final Polish
- [ ] Task: Create a Bias Efficacy Simulation.
    - [ ] Implement a specialized simulation test where two tools could solve a problem, and verify the agent chooses the one with higher weight.
- [ ] Task: Final UI polish (spacing, icons, tooltips explaining the bias system).
- [ ] Task: Run full suite of relevant tests.
- [ ] Task: Conductor - User Manual Verification 'Phase 4: Verification & Polish' (Protocol in workflow.md)
