Files
openhuman/scripts
Steven EnamakelandGitHub 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
2026-04-13 20:06:00 -07:00
..
2026-03-26 17:04:46 -07:00
2026-02-05 19:29:21 +05:30
2026-03-30 17:52:32 -07:00
2026-03-29 10:30:18 -07:00