Skip to content

fix: surface dynamic_context in Agent Tools & Metadata modal (#932)#973

Open
burakkeless wants to merge 1 commit into
OpenHands:mainfrom
burakkeless:932-bug-agent-tools-metadata-modal-omits-dynamic-context
Open

fix: surface dynamic_context in Agent Tools & Metadata modal (#932)#973
burakkeless wants to merge 1 commit into
OpenHands:mainfrom
burakkeless:932-bug-agent-tools-metadata-modal-omits-dynamic-context

Conversation

@burakkeless
Copy link
Copy Markdown

Summary

Closes #932.

The "Agent Tools & Metadata" modal rendered only system_prompt.text and tools from the backend SystemPromptEvent. That event actually carries a third content field, dynamic_context, which was never referenced in the frontend (nor in the SystemPromptEvent TS interface).

dynamic_context is part of the system message the model actually receives — and it's larger than the static prompt (≈17.2k vs ≈14.4k chars in a real event). It holds the runtime-injected sections: <CURRENT_DATETIME>, <SKILLS>, <RUNTIME_SERVICES>, and <CUSTOM_SECRETS>. As a result the modal showed less than half of the agent's true system context.

Changes

  • Type: add optional dynamic_context?: TextContent to the SystemPromptEvent interface (optional, so older persisted events stay valid).
  • Adapter: adaptSystemMessage now surfaces dynamicContext on SystemMessageForModal.
  • UI: new "Dynamic Context" tab in the modal, rendered only when the event has dynamic context. Reuses the existing monospace content renderer for fidelity with what the agent receives.
  • Modal reset: reset to the System tab on open, so a previously selected but now-hidden tab can't leave the modal showing an empty panel.
  • Secrets: per the issue's note, added a defensive client-side redactCustomSecrets backstop that re-masks any unmasked value inside a <CUSTOM_SECRETS> block (KEY=value / KEY: value, tolerant of a truncated block) before display.
  • i18n: SYSTEM_MESSAGE_MODAL$DYNAMIC_CONTEXT_TAB added for all locales.

Testing

  • redact-custom-secrets.test.ts (new): both separators, multiple secrets, truncated block, idempotency, leaves text outside the block untouched.
  • system-message-adapter.test.ts: dynamic_context absent → null; present → surfaced; unmasked secret → redacted.
  • npm run typecheck and the targeted vitest files pass locally (13 tests).

…ds#932)

The backend SystemPromptEvent carries three content fields
(system_prompt, tools, dynamic_context), but the frontend only read the
first two. dynamic_context (datetime, skills catalog, runtime services,
custom secrets) is part of the system message the model actually
receives and is larger than the static prompt, so the modal showed less
than half of the agent's true context.

- Add optional dynamic_context to the SystemPromptEvent interface
- Surface it via adaptSystemMessage and a new "Dynamic Context" tab
- Defensively redact unmasked <CUSTOM_SECRETS> values client-side
- Reset to the System tab on open so a now-hidden tab can't leave an
  empty panel
- Add tests and translations for all locales

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

Someone is attempting to deploy a commit to the openhands Team on Vercel.

A member of the Team first needs to authorize it.

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.

[Bug]: Agent Tools & Metadata modal omits dynamic_context from the system prompt

1 participant