docs(adr): context-aware token for agent-initiated operations#716
docs(adr): context-aware token for agent-initiated operations#716
Conversation
…tions Proposes a scoped token pattern that lets agents actively interact with platform APIs (fetch messages, update threads, cross-channel notify) instead of relying on always-on transport-layer context injection. Supersedes PR #527 approach of always prepending quoted message content. Related: #339
This comment has been minimized.
This comment has been minimized.
chaodu-agent
left a comment
There was a problem hiding this comment.
LGTM ✅ — Clean ADR that formalizes an existing pattern (steering doc + curl for thread titles) into a documented architecture. Ready to merge with minor suggestions.
四問框架 Review
1. What problem does it solve?
PR #527 always prepended quoted message content at the OAB transport layer (~500 tokens per reply), even when the agent already had context. This ADR proposes an on-demand pattern: give the agent a scoped platform token so it can pull context only when needed.
2. How does it solve it?
New ADR file (docs/adr/context-aware-token.md) proposing:
- Agent gets
DISCORD_CONTEXT_TOKENenv var - Steering docs define allowed/denied operations (trust boundary)
- OAB core stays unchanged — purely agent-side capability
- Covers 4 use cases: smart quote resolution, cross-channel coordination, thread title management, historical context retrieval
3. What was considered?
- PR #527 always-on approach (superseded) — wastes tokens, wrong layer
- This ADR on-demand approach — agent decides when to fetch
4. Is this the best approach?
For an ADR, yes. The document is well-structured, follows existing ADR conventions in the repo, and the phased rollout plan is pragmatic.
Traffic Light
🟢 INFO — Follows existing ADR format (matches custom-gateway.md, multi-platform-adapters.md). Good prior art section linking to PR #527 and issue #339.
🟢 INFO — The "OAB core doesn't change" principle is well-articulated and consistent with OAB philosophy.
🟡 NIT — Section 4 Security: "Trust boundary enforced by steering docs" is honest but worth noting that this is fundamentally a soft boundary. LLMs can hallucinate tool calls or ignore steering doc constraints. Consider adding a sentence acknowledging this is a known limitation of the pattern, not a bug in the design.
🟡 NIT — The ADR references ./custom-gateway.md and ./multi-platform-adapters.md in the References section — these exist on main ✅. But it also references PR #527 as "superseded" — since #527 is already closed, consider noting the close date for future readers.
🟡 NIT — Open Questions table: "How to handle platforms without API tokens?" — LINE and Telegram both have API tokens (LINE Channel Access Token, Telegram Bot Token). The question might be better framed as "platforms with different auth models" rather than "without API tokens."
Disclosure: This PR was authored by chaodu-agent (me). I am reviewing my own PR for completeness and to surface any issues before maintainer review.
This comment has been minimized.
This comment has been minimized.
resolution Address review feedback: - Add Section 2: Prior Art with OpenClaw (mediated architecture, security advisories) and Hermes Agent (tool-based architecture, defense-in-depth) - Rewrite Section 5: Security evolution path from behavioral-only to defense-in-depth (audit logging → proxy enforcement → scoped tokens) - Add Section 6: Concrete #339 resolution path with 3 steps and acceptance criteria - Add rollout timeline with version targets and acceptance criteria - Clarify scope definition is documentation convention, not security boundary - Add comparison tables for prior art and security model evolution
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
- §6: distinguish reply (Discord provides referenced_message) vs non-reply historical lookup (token needed) scenarios - §5: rename security phases to 'Level 1-4' (Security Maturity Levels) to avoid confusion with §10 Rollout Plan 'Phase 1-5'; fix §4→§5 cross-refs - §3: add prominent callout that same bot token is a convenience shortcut for trusted single-operator deployments only - §9: mark Open Questions row 1 as Decided (per-platform tokenization)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
LGTM ✅ — Well-structured ADR with solid prior art research and pragmatic security evolution path. Three cosmetic NITs, no blocking issues. 📋 Four-Question Framework Analysis1. What problem does this solve?OAB agents are currently passive receivers — they get a prompt and return a response. Real-world usage requires agents to actively interact with platforms (update thread titles, fetch historical messages, cross-channel coordination). PR #527 solved one edge case (reply/quote context) with always-on prepending at ~500 tokens per reply. This ADR proposes a context-aware token pattern that lets agents pull context on demand, solving #339 and enabling capabilities that were previously impossible. 2. How does it solve it?
3. What alternatives were considered?
4. Is this the best approach?Yes, for OAB's constraints. The ADR honestly acknowledges the security gap (Level 1 is behavioral-only) and provides a concrete evolution path. The tradeoff between pragmatism (works with any agent that has shell access) and security (no technical enforcement initially) is well-reasoned and appropriate for trusted single-operator deployments. 🚦 Traffic Light🟢 INFO — Strengths:
🟢 INFO — Baseline check:
🟡 NIT 1: §10 Rollout Plan Phase 1 could echo the §3 security note about same-bot-token being a convenience shortcut for trusted single-operator deployments only — saves readers from scrolling back to §3. 🟡 NIT 2: §6 Acceptance Criteria uses 🟡 NIT 3: §9 Open Questions row 1 uses strikethrough for "Decided" — some renderers handle this poorly. Consider adding a "Status" column or moving decided items to §3. 📊 Baseline Check
|
chaodu-agent
left a comment
There was a problem hiding this comment.
LGTM ✅ — Reviewed and recommended for approval. Well-structured ADR with solid prior art research and pragmatic security evolution path. Three cosmetic NITs noted (non-blocking).
Summary
Proposes a context-aware token pattern that gives agents the ability to actively interact with platform APIs when they judge it necessary — instead of relying on always-on transport-layer context injection.
Motivation
Discussion during review of PR #527 (reply/quote context) revealed that always prepending quoted message content at the OAB transport layer:
A scoped token lets the agent pull context on demand and enables capabilities that were previously impossible:
Key Design Principle
OAB core doesn't change. The token lives in the agent's environment, configured by the user. Allowed operations are defined in steering docs. OAB remains a passive transport layer.
Relationship to PR #527
This ADR supersedes PR #527's approach. PR #527 will be closed in favor of this design direction.
Related: #339
Discord discussion: https://discord.com/channels/1491295327620169908/1491365150664560881/1500514858775482418