Files
openhuman/docs
Steven EnamakelandGitHub 57d307ad1e feat(agent): simplify harness + trim bundled prompts (#500)
* Add built-in agent definitions and prompts for orchestrator, planner, code executor, skills agent, researcher, critic, archivist, and tool maker

- Introduced a new module for built-in agent definitions, allowing for easy addition of agents through a structured format.
- Created TOML configuration files for each agent, detailing their properties such as id, display name, usage context, and tool specifications.
- Developed corresponding prompt files that outline the responsibilities and rules for each agent, enhancing their functionality and usability.
- Implemented a loading function to parse these definitions into usable agent structures, ensuring all agents are correctly initialized and validated.

* Remove deprecated archetypes and related components from the multi-agent harness

- Deleted the `archetypes.rs`, `dag.rs`, `executor.rs`, and `types.rs` files, which contained the definitions and implementations for agent archetypes, task DAGs, and execution logic.
- Updated the `builtin_definitions.rs` and `definition.rs` files to remove references to the now-removed archetypes, streamlining the agent definition process.
- Refactored the `mod.rs` file to eliminate unused modules and clarify the structure of the multi-agent harness.
- Adjusted comments and documentation to reflect the removal of the DAG orchestration flow, emphasizing the current sub-agent delegation model.

* Remove unused `ArchetypeConfig` from schema exports in `mod.rs` to streamline configuration management.

* Implement context guard and memory management features in the harness module

- Introduced `ContextGuard` to monitor context utilization and trigger auto-compaction when usage exceeds defined thresholds.
- Added `scrub_credentials` function to sanitize sensitive information from tool outputs.
- Implemented history management functions to trim conversation history and build compaction transcripts.
- Created `build_tool_instructions` to generate tool usage guidelines for the system prompt.
- Developed `memory_context` functions to manage user memory and relevant context for conversations.
- Enhanced the `tool_loop` to integrate the new context management and tool invocation logic.

This update improves the agent's ability to manage context effectively, ensuring efficient memory usage and secure handling of sensitive data.

* Refactor agent module imports to use the harness instead of loop_

- Updated import paths in `dispatcher.rs`, `memory_loader.rs`, `mod.rs`, `dispatch.rs`, and `startup.rs` to replace references from the `loop_` module to the `harness` module.
- This change enhances module organization and aligns with the recent architectural updates in the agent structure.

* Remove cost tracking and context assembly modules from the agent structure

- Deleted `cost.rs` and `context_assembly.rs` files, which handled token cost tracking and context assembly for the multi-agent harness, respectively.
- Updated `mod.rs` files to remove references to the deleted modules, streamlining the agent's organization and focusing on essential components.
- This cleanup enhances maintainability and aligns with the current architectural direction of the project.

* Remove identity module and related configurations from the agent structure

- Deleted the `identity.rs` file, which contained the AIEOS identity handling logic and related structures.
- Updated `mod.rs` and other files to remove references to the deleted identity module, streamlining the agent's organization.
- This change simplifies the codebase and aligns with the decision to rely solely on OpenClaw markdown files for identity management.

* Enhance agent prompts with improved formatting and clarity

- Added spacing for better readability in the prompts of the Archivist, Code Executor, Critic, Orchestrator, Researcher, Skills Agent, and Tool Maker agents.
- Updated the table formatting in the Orchestrator prompt for consistency and clarity.
- These changes improve the overall presentation and usability of agent documentation, making it easier for users to understand agent responsibilities and rules.

* Remove REPL functionality and related components from the agent structure

- Deleted the `repl.rs` file, which contained the implementation for the interactive REPL.
- Removed references to the REPL in `cli.rs`, `mod.rs`, and other related files, streamlining the agent's organization.
- Eliminated unused REPL session handling logic from the agent schemas and local AI operations, enhancing maintainability and focusing on essential components.
- This cleanup aligns with the current architectural direction of the project, simplifying the codebase.

* Refactor imports and clean up configuration exports

- Updated import paths in `startup.rs` to include `host_runtime` from the correct module.
- Streamlined the export statements in `mod.rs` and `schema/mod.rs` for better organization and clarity.
- Removed unnecessary line breaks in the export lists to enhance readability and maintainability of the configuration schema.

* Remove unused history management functions and clean up agent module exports

- Deleted the `history.rs` and `session.rs` files, which contained functions for managing conversation history and session handling.
- Updated `mod.rs` to remove references to the deleted modules and streamline the agent's organization.
- Cleaned up import statements in `mod.rs` and other files to enhance clarity and maintainability of the codebase.

* Add agent harness module with builder, runtime, and turn management

- Introduced a new `harness` module for the `Agent`, encapsulating the `AgentBuilder`, runtime accessors, and turn lifecycle management.
- Implemented the `AgentBuilder` fluent API for constructing `Agent` instances with customizable configurations.
- Developed the `turn` method to handle user interactions, tool execution, and context management within the agent.
- Created a `runtime` module for public accessors and utility functions related to agent operations.
- Added comprehensive unit and integration tests to ensure the functionality of the new agent structure and its components.

* Remove classifier and traits modules from the agent structure

- Deleted the `classifier.rs` and `traits.rs` files, which contained the classification logic and core agent traits, respectively.
- Updated `mod.rs` to remove references to the deleted modules, streamlining the agent's organization.
- This cleanup enhances maintainability and focuses on essential components of the agent architecture.

* Refactor agent prompt structure and remove unused files

- Updated the `prompt.rs` file to streamline the orchestrator's logic by removing unnecessary tool documentation references and simplifying the file list.
- Deleted several prompt files (`AGENTS.md`, `BOOTSTRAP.md`, `CONSCIOUS_LOOP.md`, `MEMORY.md`, `README.md`, `TOOLS.md`) to declutter the project and focus on essential components.
- Adjusted the `harness/mod.rs` file to change module visibility from public to crate-level for better encapsulation.
- These changes enhance maintainability and align with the current architectural direction of the project.

* Refactor bootstrap file handling and update tests

- Simplified the list of bundled prompt files in `prompt.rs` by removing references to `AGENTS.md` and `TOOLS.md`, focusing on essential identity files.
- Adjusted the logic for injecting `MEMORY.md` to be optional, ensuring it only appears if it exists.
- Updated test cases in `common.rs`, `identity.rs`, and `prompt.rs` to reflect the changes in the bootstrap file structure and ensure accurate validation of the new logic.
- These modifications enhance clarity and maintainability of the codebase while aligning with the current project architecture.

* Implement agent delegation tools and browser automation features

- Introduced new tools for agent delegation, including `ArchetypeDelegationTool`, `AskClarificationTool`, `DelegateTool`, and `SkillDelegationTool`, enhancing the agent's ability to manage tasks through specialized sub-agents.
- Added `SpawnSubagentTool` for delegating tasks to sub-agents, allowing for more complex workflows and improved task management.
- Implemented browser automation capabilities with `BrowserOpenTool`, enabling secure opening of approved URLs in the Brave Browser.
- Enhanced the `BrowserTool` with pluggable backends for improved automation and user interaction.
- Added `ImageInfoTool` for extracting metadata from images, supporting future multimodal capabilities.
- Organized tools into a new `impl` module structure for better maintainability and clarity in the codebase.

* Refactor imports and clean up tool implementations

- Updated import statements across various tool implementations to ensure consistency and clarity, particularly in the `traits.rs` file.
- Removed unnecessary line breaks and adjusted module paths for better organization.
- Cleaned up test files by removing trailing whitespace, enhancing code readability and maintainability.
- These changes streamline the codebase and improve the overall structure of tool-related components.

* Update built-in definitions and prompt handling for clarity and consistency

- Revised the test for built-in agent definitions to dynamically reference the length of `BUILTINS`, enhancing maintainability.
- Clarified documentation for the `system_prompt` field in `AgentDefinition`, emphasizing the default behavior and usage of inline prompts.
- Simplified the `build_system_prompt` function by removing unnecessary conditional logic, ensuring a more straightforward return of the prompt string.

* Enhance agent definition loading and documentation clarity

- Updated the `load_file` function to reject definitions with missing or empty `system_prompt`, ensuring custom definitions are properly validated.
- Added a new test to verify that definitions lacking a `system_prompt` are correctly rejected, improving robustness.
- Clarified documentation for built-in definitions and TOML parsing, emphasizing compile-time guarantees and runtime checks.
- Improved the logic for checking the existence of `MEMORY.md` to prevent errors from stray directories, enhancing file handling reliability.
2026-04-10 21:41:45 -07:00
..