Skip to content

fix(agent): restore modern domain context after restart - #34

Merged
dajiaohuang merged 1 commit into
mainfrom
fix/modern-context-sync-restart
Aug 29, 2026
Merged

fix(agent): restore modern domain context after restart#34
dajiaohuang merged 1 commit into
mainfrom
fix/modern-context-sync-restart

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Problem

After a persisted Narrative conversation and Hosted Agent restart, the MCP reconnects but pre-turn authoritative context synchronization raises unsupported schema.

Modern MCP wrappers intentionally remove trusted campaign_id from the model-visible input schema and retain it in _trusted_arguments. The synchronizer only recognized a visible action + campaign_id pair, so the exact modern campaign_query shape was rejected before the wrapper could inject the Host-owned campaign.

Solution

  • recognize the modern shape only when action remains visible and the MCP wrapper explicitly advertises trusted campaign_id
  • pass only action=get for that shape, letting the bound request context inject/override campaign identity
  • bind a missing request campaign from the persisted authoritative binding
  • reject a conflicting request campaign before any tool executes
  • keep legacy view + payload and visible action + campaign_id compatibility
  • continue rejecting action-only or otherwise unknown schemas

Verification

  • uv run ruff check nanobot --select F
  • uv run ruff check nanobot/agent/loop.py tests/agent/test_domain_context.py
  • uv run python -m pytest -q tests/agent/test_domain_context.py (16 passed)
  • uv run python -m pytest -q tests/agent/test_domain_context.py tests/tools/test_mcp_tool.py tests/tools/test_mcp_v2_contract.py tests/apps/test_hosted_worker.py (141 passed)
  • uv run python -m pytest -q tests (5393 passed, 73 skipped)

Regression coverage persists and reloads a Narrative session across a simulated process restart, registers a freshly reconnected modern campaign tool, verifies v2 trusted campaign injection, and covers unsupported untrusted schemas plus cross-campaign rejection.

@dajiaohuang
dajiaohuang merged commit 056f295 into main Aug 29, 2026
11 checks passed
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