Skip to content

Agent files: wire CPT contents into the runtime system prompt#74

Open
lezama wants to merge 1 commit into
mainfrom
feat/agent-files-runtime
Open

Agent files: wire CPT contents into the runtime system prompt#74
lezama wants to merge 1 commit into
mainfrom
feat/agent-files-runtime

Conversation

@lezama
Copy link
Copy Markdown
Owner

@lezama lezama commented May 19, 2026

Summary

Wires openclawp_agent_file CPT contents (shipped in PR #71) into the runtime system prompt assembler. The runner now reads files targeted at the current agent (own + globals) and appends them to the agent's static description before passing it to wp_ai_client_prompt()->using_system_instruction().

  • New OpenclaWP_Agent_Files_Store::for_agent_as_text( $agent_slug ) returns the files concatenated as plain text (=== title ===\nbody\n…).
  • New openclawp_runner_system_instruction filter lets other plugins layer in further per-turn customisation.

Why

PR #71 shipped the CPT + admin UI but the contents didn't reach the runtime — admins could author files but the agent ignored them. This PR closes that loop.

Test plan

  • On an install with no agent files, system prompts are identical to pre-PR.
  • Author a file titled AGENTS.md with agent_slug = '' and body "Always reply in upper-case." — every agent turn now sees it.
  • Author a file targeted at one agent slug. Other agents do not see it.
  • PHPUnit unit suite: still passes.

🤖 Generated with Claude Code

The `openclawp_agent_file` CPT shipped in #71 was authored but never read
by the runner. Append the per-agent file set (globals + agent-targeted)
to the agent's static description before passing it to
`using_system_instruction()`.

- New `OpenclaWP_Agent_Files_Store::for_agent_as_text( $agent_slug )`
  concatenates the matching files as `=== title ===\nbody\n…` plain text.
- New `openclawp_runner_system_instruction` filter lets other plugins
  layer in further per-turn customisation after agent files are merged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant