Skip to content

UP-17: Structured message metadata for agent orchestration#22

Merged
Killea merged 5 commits intoKillea:mainfrom
bertheto:feat/structured-metadata
Mar 1, 2026
Merged

UP-17: Structured message metadata for agent orchestration#22
Killea merged 5 commits intoKillea:mainfrom
bertheto:feat/structured-metadata

Conversation

@bertheto
Copy link
Contributor

@bertheto bertheto commented Mar 1, 2026

Summary

Formalises the existing metadata passthrough on msg_post into a typed orchestration API, enabling structured agent handoff and stop signalling.

Changes

MCP Schema (src/mcp_server.py)

  • msg_post: document handoff_target, stop_reason, attachments with types and descriptions
  • msg_wait: add for_agent parameter for directed handoff routing

CRUD (src/db/crud.py)

  • Emit msg.handoff SSE event when metadata.handoff_target is set
  • Emit msg.stop SSE event when metadata.stop_reason is set

Dispatch (src/tools/dispatch.py)

  • handle_msg_post: return handoff_target and stop_reason in tool result
  • handle_msg_wait: for_agent filter in poll via _metadata_targets helper

Web UI (src/static/index.html, src/static/css/main.css)

  • Handoff badge (arrow pill with target agent) in message header
  • Stop-reason tag (colour-coded: green=convergence/complete, yellow=timeout, red=error, purple=impasse)

Tests

  • tests/test_structured_metadata.py: 11 pytest unit tests (all green)
  • frontend/src/tests/structured-metadata.test.js: 8 Vitest tests (all green)

Recognised metadata keys

Key Description SSE Event
handoff_target Agent ID to receive next message msg.handoff
stop_reason Why agent ends its turn (convergence, timeout, error, complete, impasse) msg.stop
attachments File/image attachments (existing) --

Backward Compatibility

No database schema changes. All metadata keys are optional. Existing callers that pass arbitrary metadata objects continue to work unchanged.

bertheto and others added 5 commits March 1, 2026 19:25
Formalise the existing metadata passthrough into a typed orchestration API:

- msg_post schema: document handoff_target, stop_reason, attachments as
  recognised metadata keys with types and descriptions
- SSE events: emit msg.handoff and msg.stop events when those keys are set,
  enabling SSE subscribers to react to handoffs and agent stops without polling
- msg_wait for_agent filter: only wake when metadata.handoff_target matches,
  enabling directed agent-to-agent handoff patterns
- Response: handle_msg_post returns handoff_target / stop_reason in the
  tool result for immediate discoverability
- Web UI: handoff badge (arrow pill) and stop-reason tag (colour-coded per
  reason) appear in the message header row
- Tests: 11 pytest unit tests + 8 Vitest DOM/logic tests (all green)

Fully backward-compatible — no schema migration needed (metadata column exists).
The feat/structured-metadata branch inherited crud.py changes that
reference agents.skills (from UP-15 work), but the corresponding DB
migration was missing, causing sqlite3.OperationalError in CI.

UP-15 (PR Killea#21) is still pending review; this migration makes UP-17
self-contained regardless of merge order.
crud.py (inherited from UP-15 work) passes skills=skills_json to AgentInfo()
but the field was missing from the dataclass, causing TypeError in CI.

This makes UP-17 self-contained regardless of UP-15 (PR Killea#21) merge order.
@Killea Killea merged commit 594616a into Killea:main Mar 1, 2026
1 check 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.

2 participants