terraphim / terraphim/terraphim-ai
Implement JSONL RPC envelope for agent-orchestrator communication
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 62
- Forks
- 5
- Avg merge
- 2h 27m
- Merged PRs (30d)
- 1
Description
Context
ADF currently communicates with agents via unstructured stdout/stderr pipes. This causes:
- SIGPIPE kills when stderr pipe is dropped
- Fragile text parsing for cost/session/status extraction
- No message framing, idempotency, or error typing
Proposal
Implement a JSONL envelope protocol inspired by Piwork's taskd RPC spec (docs/runtime-taskd-rpc-spec.md).
Envelope Format
Agent -> Orchestrator (event):
{"type": "event", "event": "cost_update", "agent": "security-sentinel", "ts": "...", "payload": {...}}
Orchestrator -> Agent (command, future):
{"id": "req_01", "type": "pause", "payload": {"reason": "budget_exceeded"}}
Key Properties
- Strict envelope:
{type, event/id, payload}(payload required even if empty) - Idempotency: duplicate request IDs with same payload produce no duplicate effects
- Typed error codes with retryable flag
- State recovery:
runtime_get_stateequivalent after reconnect
Integration
- For Claude agents: wrap
--output-format stream-jsonevents in ADF envelope - For Codex agents: gracefully degrade to unstructured mode
- New agents: require envelope support as spawn prerequisite
Benefits
- Foundation for cost tracking (#638), session persistence (#639), activity log (#641)
- Eliminates SIGPIPE bug (structured framing detects incomplete messages)
- Enables future Agent SDK migration
References
- Piwork taskd RPC spec: https://github.com/ferologics/Piwork/blob/main/docs/runtime-taskd-rpc-spec.md
- Plan:
cto-executive-system/plans/adf-architecture-improvements.md(item 1.3) - Blocks: #638, #639, #641
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading docs/runtime-taskd-rpc-spec.md and item 1.3 in cto-executive-system/plans/adf-architecture-improvements.md, then inspect the Claude stream-json and Codex agent communication paths. Done means the proposed envelope, idempotency, typed errors, state recovery, and graceful Codex fallback are implemented across the listed integrations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, backend-api-design, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100