mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-28 13:32:23 +00:00
13ce2cdcbf64107f0809f5bcb0b484578887bc0a
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3db06e8e92 |
feat(prompt): per-agent PROFILE.md + MEMORY.md injection, 2K-char cap (#550)
* Enhance debug-agent-prompts script and prompt rendering logic - Updated the `debug-agent-prompts.sh` script to always run `cargo build`, ensuring the latest binary is used and preventing stale binaries from affecting agent behavior. - Modified the output directory handling to wipe and recreate it at the start of each run, ensuring a clean snapshot of the current agent set. - Enhanced the `render_subagent_system_prompt` function to unconditionally inject `PROFILE.md`, ensuring it is included even when identity information is omitted, thus improving personalization for agents like `welcome`. - Added tests to verify the correct injection of `PROFILE.md` under various conditions, ensuring robust functionality and preventing regressions in prompt rendering. * Enhance debug-agent-prompts script to utilize the currently-logged-in user's workspace - Updated the `debug-agent-prompts.sh` script to point to the real user's workspace, ensuring onboarding-generated files like `PROFILE.md` are included in the dump. - Improved workspace resolution logic to prioritize the active user's workspace, falling back to default paths as necessary. - Added error handling for cases where the workspace is not found, providing clear guidance for users to complete onboarding or specify a different workspace. - Enhanced output to include the presence state of `PROFILE.md`, improving visibility into the onboarding process. * Add profile inclusion for user-facing agents to enhance personalization - Updated agent TOML configurations for orchestrator, trigger reactor, trigger triage, and welcome agents to include user profile data by setting `omit_profile = false`. This allows agents to personalize interactions based on user context derived from `PROFILE.md`. - Refactored the `AgentDefinition` struct to include a new `omit_profile` field, ensuring that agents can opt-in to utilize user profile information. - Enhanced prompt rendering logic to conditionally inject `PROFILE.md` based on the `omit_profile` flag, improving the relevance and personalization of agent responses. - Updated tests to verify the correct behavior of profile inclusion across various agents, ensuring robust functionality and preventing regressions. * Implement `omit_profile` flag in `AgentBuilder` and `Agent` for profile management - Added a new `omit_profile` field to the `AgentBuilder` struct, allowing agents to specify whether to include user profile data in their responses. - Updated the `Agent` struct to mirror the `omit_profile` flag, ensuring that the profile inclusion logic is consistent across agent instances. - Enhanced the `omit_profile` method in `AgentBuilder` to facilitate the configuration of this flag during agent construction. - Adjusted the default behavior to omit profiles for legacy agents while allowing opt-in for specific agents that require user context. - Updated documentation to clarify the purpose and usage of the `omit_profile` flag in agent definitions. * Implement profile management enhancements in Agent and prompt rendering - Introduced an `omit_profile` flag in the `AgentBuilder` and `Agent` to control the inclusion of user profile data in responses, defaulting to true for legacy paths. - Updated the `Agent` struct to utilize the `omit_profile` flag, ensuring consistent profile inclusion logic across agent instances. - Enhanced prompt rendering logic to conditionally include or exclude `PROFILE.md` based on the `omit_profile` setting, improving personalization for user-facing agents. - Added tests to verify the correct behavior of profile inclusion and omission across various scenarios, ensuring robust functionality and preventing regressions. * feat(prompt): per-agent MEMORY.md injection with 2000-char cap Add `omit_memory_md` to `AgentDefinition` (mirror of `omit_profile`) and inject `MEMORY.md` alongside `PROFILE.md` in both the main and sub-agent render paths. Both user-specific files are capped at `USER_FILE_MAX_CHARS = 2_000` (~1000 tokens each) via a new `inject_workspace_file_capped` helper so growing on-disk files can't balloon the system prompt. Opt-in on the same four user-facing agents (welcome, orchestrator, trigger_triage, trigger_reactor). Narrow specialists leave it at the `true` default. KV-cache contract is documented on the flag, the injection sites, and the capped helper: rendered bytes are frozen per session, and mid-session writes only surface on the next session. Pinned with a new `rendered_subagent_system_prompt_is_byte_stable_across_repeat_calls` test plus coverage for injection / opt-out / 2000-char cap. * refactor(tests): clean up test formatting and improve readability - Removed unnecessary line breaks and adjusted indentation in test files for better consistency and clarity. - Reformatted the `RewardsCouponSection` test to enhance readability and maintain a uniform style across test cases. - Ensured that all test cases align with the updated formatting standards, improving overall maintainability. * feat(debug-agent-prompts): enhance output directory validation and canonicalization - Improved the `debug-agent-prompts.sh` script to validate and canonicalize the output directory (`OUT_DIR`) before performing any file operations. - Added checks to reject relative paths and ensure the output directory is an absolute path, preventing potential catastrophic deletions. - Implemented a `canonicalize` function that uses `realpath` or `readlink` to resolve paths, with a fallback to Python for compatibility on barebones systems. - Enhanced error handling to provide clear feedback when the output directory cannot be validated or canonicalized. - Ensured that the script operates on the canonicalized path for all subsequent commands, maintaining consistency and safety. * style(turn): single-line rustfmt for redacted log branch |
||
|
|
1cb70e3234 |
feat: P-Format tool calls, user memory injection, planner upgrades (#511)
* feat(agent): introduce debug agent prompts script and CLI for prompt inspection
- Added `scripts/debug-agent-prompts.sh` to dump system prompts for built-in agents, facilitating prompt engineering reviews.
- Implemented `openhuman agent` CLI commands for inspecting agent definitions and rendering prompts.
- Updated `.gitignore` to exclude local prompt dumps and added version bump for `openhuman` to 0.52.5.
- Introduced `debug_dump` module for shared prompt rendering logic, enhancing debugging capabilities across the application.
* feat(pformat): introduce P-Format tool calls for efficient parameter handling
- Added a new module `pformat` to implement P-Format ("Parameter-Format") tool calls, which significantly reduce token usage in tool invocations.
- Updated the agent module to include the new `pformat` module.
- Enhanced the context management by integrating user memory summaries from the tree summarizer, optimizing the prompt rendering process.
- Introduced constants for user memory character limits to ensure efficient memory usage across namespaces.
- Implemented a new `UserMemorySection` in the prompt to display distilled long-term context, improving the agent's ability to leverage learned information during interactions.
- Refactored the tree summarizer store to collect root-level summaries with character caps, ensuring manageable context sizes in prompts.
* feat(dispatch): implement PFormatToolDispatcher for efficient tool call handling
- Introduced `PFormatToolDispatcher`, a new dispatcher that utilizes P-Format for compact tool call syntax, significantly reducing token usage during interactions.
- Updated the agent's session builder to support the new dispatcher, allowing for a seamless transition to P-Format as the default for text-based providers.
- Enhanced the prompt rendering process to accommodate P-Format, ensuring backward compatibility with existing JSON tool calls.
- Modified the context management to reflect the new tool call format, improving the overall efficiency of prompt generation and tool interaction.
- Added tests to validate the correct rendering of tool signatures in P-Format, ensuring that the new format is correctly integrated into the system.
* feat(tests): add comprehensive tests for PFormatToolDispatcher functionality
- Introduced multiple tests for the `PFormatToolDispatcher`, validating its ability to parse tool calls from both P-Format and JSON formats.
- Implemented tests to ensure correct handling of multiple tool call tags and the dispatcher’s fallback behavior to JSON when P-Format is ignored.
- Enhanced the `render_main_agent_dump` function to include the dispatcher instructions, ensuring accurate context for tool usage in debug outputs.
- Updated the tree summarizer tests to verify namespace filtering and summary collection with respect to character limits, improving overall test coverage and reliability.
* feat(prompt): enhance tool signature rendering with P-Format support
- Introduced a new function `render_pformat_signature_for_box_tool` to generate P-Format signatures for tools, improving consistency in tool call formatting.
- Updated the `render_subagent_system_prompt` function to utilize the new P-Format signatures, ensuring alignment with the main agent's tool call protocol.
- Enhanced documentation to clarify the use of P-Format in tool calls, including detailed instructions for argument handling and formatting within the tool use protocol.
* feat(planner): update agent configuration and enhance planning context
- Revised the `when_to_use` description to emphasize the agent's ability to gather real context through memory recall and web searches.
- Increased `max_iterations` from 5 to 8 to allow for more complex planning scenarios.
- Changed `omit_memory_context` to false, enabling the agent to utilize memory context during planning.
- Updated the tools list to include `memory_recall`, `memory_store`, `memory_forget`, and `web_search_tool`, enhancing the agent's capabilities for context gathering.
- Expanded the prompt documentation to instruct users on gathering context before planning, ensuring more informed and effective task decomposition.
* style: apply cargo fmt to new and modified files
* feat(debug): enhance error handling and logging in debug-agent-prompts and tool dispatching
- Added error handling for missing output directory in `debug-agent-prompts.sh`, ensuring clearer feedback for users.
- Introduced a verbose flag in `agent_cli.rs` to control logging output, improving usability during debugging.
- Refactored tool response parsing in `dispatcher.rs` to prefer p-format calls while maintaining compatibility with JSON, enhancing response handling.
- Updated session builder in `builder.rs` to finalize dispatcher selection after tool list preparation, ensuring accurate tool handling.
- Improved debug dump functionality in `debug_dump.rs` to clarify the context of the dump process, ensuring better understanding of the output.
- Enhanced prompt rendering functions to support explicit tool call formats, improving flexibility in subagent interactions.
* feat(cli, prompt): enhance logging and tool call format handling
- Added debug logging for the agent subcommand in `cli.rs`, improving traceability during command execution.
- Updated the `render_subagent_system_prompt_with_format` function in `prompt.rs` to support multiple tool call formats (P-Format, JSON, Native), ensuring consistent output and flexibility for subagent interactions.
- Refactored tool call protocol documentation to clarify usage across different formats, enhancing user understanding and implementation.
* fix: address PR review — 8 findings
1. scripts/debug-agent-prompts.sh: validate --out argument exists
2. agent_cli.rs: silence logger in run_list before Config::load_or_init
3. dispatcher.rs: per-tag p-format/JSON selection (no all-or-nothing)
4. builder.rs: move pformat_registry build after orchestrator tools
5. debug_dump.rs: fall back to bundled prompt location for File sources
6. store.rs: fix char/byte mixing in total_cap computations
7. prompt.rs: thread ToolCallFormat into render_subagent_system_prompt
8. cli.rs: add debug trace on agent dispatch + lower dispatcher log
|