feat: tool trace + platform instructions (review-passed) - #1686
Merged
Conversation
…ability Every A2A response now includes a tool_trace — the list of tools/commands the agent actually invoked during execution. This enables verifying agent claims against what they actually did, catches hallucinated "I checked X" responses, and provides an audit trail for the CEO to control hundreds of agents by checking the top-level PM's trace. Changes: - Python runtime: collect tool name/input/output_preview on every on_tool_start/on_tool_end event, embed in Message.metadata.tool_trace - Go platform: extract tool_trace from A2A response metadata, store in new activity_logs.tool_trace JSONB column with GIN index - Activity API: expose tool_trace in List and broadcast endpoints - Migration 039: adds tool_trace column + GIN index Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a configurable instruction injection system that prepends rules to every agent's system prompt. Instructions are stored in the DB and fetched at workspace startup, supporting three scopes: - Global: applies to all agents (e.g., "verify with tools before reporting") - Team: applies to agents in a specific team - Workspace: applies to a single agent (role-specific rules) Components: - Migration 040: platform_instructions table with scope hierarchy - Go API: CRUD endpoints + resolve endpoint that merges scopes - Python runtime: fetches instructions at startup via /instructions/resolve and prepends them to the system prompt as highest-priority context Initial global instructions seeded: 1. Verify Before Acting (check issues/PRs/docs first) 2. Verify Output Before Reporting (second signal before reporting done) 3. Tool Usage Requirements (claims must include tool output) 4. No Hallucinated Emergencies (CRITICAL needs proof) 5. Staging-First Workflow (never push to main directly) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BLOCKERS fixed: - instructions.go: Drop team-scope queries (teams/team_members tables don't exist in any migration). Schema column kept for future. Restored Resolve to /workspaces/:id/instructions/resolve under wsAuth — closes auth gap that allowed cross-workspace enumeration of operator policy. - migration 040: Add CHECK constraints on title (<=200) and content (<=8192) to prevent token-budget DoS via oversized instructions. - a2a_executor.py: Pair on_tool_start/on_tool_end via run_id instead of list-position so parallel tool calls don't drop or clobber outputs. Cap tool_trace at 200 entries to prevent runaway loops bloating JSONB. HIGH fixes: - instructions.go: Add length validation in Create + Update handlers. Removed dead rows_ shadow variable. Replaced string concatenation in Resolve with strings.Builder. - prompt.py: Drop httpx timeout 10s -> 3s (boot hot path). Switch print to logger.warning. Add Authorization bearer header from MOLECULE_WORKSPACE_TOKEN env var. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
new_agent_text_message returns a real Message object in production but some test mocks return a plain string. Guard with hasattr + try/except so the tool_trace assignment doesn't crash test_non_stream_events_ignored.
4 tasks
Contributor
Plugin-Dev Review — APPROVE ✅Reviewed as plugin-dev-agent on SDK Lead queue assignment. Security
Tool Trace Architecture
Architecture
Note
🤖 Generated with Claude Code |
Contributor
There was a problem hiding this comment.
Plugin-Dev Review — APPROVE ✅
Reviewed as plugin-dev-agent on SDK Lead queue assignment.
Security
wsAuthon resolve endpoint — workspace-level auth guard on the root resolve path ✓- Scope validation: only
globaland per-workspace scope values accepted ✓ 8192content length cap + migration CHECK constraints ✓MOLECULE_WORKSPACE_TOKENbearer header correctly injected intoprompt.py✓
Tool Trace Architecture
run_id-keyed map: correct per-request isolation ✓MAX_TOOL_TRACE = 200cap: bounded memory usage ✓extractToolTrace: graceful nil handling ✓- Test guard for plain string mock returns ✓
Architecture
- Team scope reserved (not yet wired) — correct ✓
org_idmigration pattern correct ✓
Ready to merge.
🤖 Generated with Claude Code
HongmingWang-Rabbit
added a commit
that referenced
this pull request
Apr 23, 2026
…m 24h retro Created the missing SHARED_RULES.md file that 6 Lead role prompts already referenced but didn't exist (causing every Lead to operate without the rules they thought they were supposed to follow). Rules derived from real failure modes observed in the 2026-04-23 retro: 1. Verify before claiming — every factual claim needs tool output 2. CRITICAL/P0/URGENT requires raw evidence — file:line + repro command 3. Circuit breaker — stop the retry cascade after 3 same-error failures 4. Do not invent phases, deadlines, or features — verify in PLAN.md 5. Token expiry is a known issue, not a P0 — auto-refresh handles it 6. Slack noise discipline — dedupe within 4h windows 7. Identity tag every external comment — [<role>-agent] prefix 8. Staging-first workflow, no exceptions Updated 33 role system prompts to reference the new SHARED_RULES.md so the rules actually flow into context for every workspace. Also added migration 041 that seeds these 8 rules into the global scope of platform_instructions (table created in PR #1686). This means OTHER org templates (not just molecule-dev) get the same baseline guidance via the /instructions/resolve endpoint at workspace startup. 24h retrospective summary that drove these rules: - 11 hallucinated CRITICAL security issues filed (all closed — validateRelPath was 5 lines above the alleged vuln in every case) - 1100+ "X Lead failed" log entries from retry cascades on token expiry - Multiple "P0 PAT NEEDED" Slack escalations within minutes of each other - Fabricated "Phase 34 needs CEO decision on partner tiers" with no source-of-truth backing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
molecule-ai Bot
pushed a commit
that referenced
this pull request
Apr 23, 2026
…m 24h retro Created the missing SHARED_RULES.md file that 6 Lead role prompts already referenced but didn't exist (causing every Lead to operate without the rules they thought they were supposed to follow). Rules derived from real failure modes observed in the 2026-04-23 retro: 1. Verify before claiming — every factual claim needs tool output 2. CRITICAL/P0/URGENT requires raw evidence — file:line + repro command 3. Circuit breaker — stop the retry cascade after 3 same-error failures 4. Do not invent phases, deadlines, or features — verify in PLAN.md 5. Token expiry is a known issue, not a P0 — auto-refresh handles it 6. Slack noise discipline — dedupe within 4h windows 7. Identity tag every external comment — [<role>-agent] prefix 8. Staging-first workflow, no exceptions Updated 33 role system prompts to reference the new SHARED_RULES.md so the rules actually flow into context for every workspace. Also added migration 041 that seeds these 8 rules into the global scope of platform_instructions (table created in PR #1686). This means OTHER org templates (not just molecule-dev) get the same baseline guidance via the /instructions/resolve endpoint at workspace startup. 24h retrospective summary that drove these rules: - 11 hallucinated CRITICAL security issues filed (all closed — validateRelPath was 5 lines above the alleged vuln in every case) - 1100+ "X Lead failed" log entries from retry cascades on token expiry - Multiple "P0 PAT NEEDED" Slack escalations within minutes of each other - Fabricated "Phase 34 needs CEO decision on partner tiers" with no source-of-truth backing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 23, 2026
molecule-ai Bot
added a commit
that referenced
this pull request
Apr 23, 2026
PR #1686 introduced two platform-level features: - Tool Trace: tool_call list in A2A metadata, stored in activity_logs.tool_trace JSONB - Platform Instructions: admin-configurable instruction text (global/workspace scope), injected as first section of every agent's system prompt at startup Demo covers 5 scenarios: admin creates global instruction, workspace-scoped instruction, agent fetches resolved instructions at boot, admin lists instructions, and query activity logs with tool_trace. Includes screencast outline (5 moments, ~90s) and TTS narration script. Co-authored-by: Molecule AI DevRel Engineer <devrel-engineer@agents.moleculesai.app> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Apr 23, 2026
molecule-ai Bot
pushed a commit
that referenced
this pull request
Apr 23, 2026
PR #1702 (SSH-backed file writes for SaaS): blog post covers fix, compute model detection, EIC-based remote write path. Ships same-day after merge. PR #1686 (Tool Trace + Platform Instructions): full positioning brief — buyer matrix, value props, competitive angle vs Langfuse/Helicone/OPA, objection handlers, cannibalization assessment (LOW). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
molecule-ai Bot
pushed a commit
that referenced
this pull request
Apr 23, 2026
PR #1702 (SSH-backed file writes for SaaS): blog post covers fix, compute model detection, EIC-based remote write path. Ships same-day after merge. PR #1686 (Tool Trace + Platform Instructions): full positioning brief — buyer matrix, value props, competitive angle vs Langfuse/Helicone/OPA, objection handlers, cannibalization assessment (LOW). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
molecule-ai Bot
added a commit
that referenced
this pull request
Apr 23, 2026
…#1867) * PMM: update ecosystem-watch — add LangGraph PR verification deferral note - Add 2026-04-22 entry: GH API 401 for external repos, LangGraph PRs #6645/#7113/#7205 still VERIFY. A2A blog uses PR#6645 as governance-gap evidence — claim is stale if PRs merged. - Update maintenance footer date to 2026-04-22 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * PMM: add Cloudflare Artifacts positioning brief Source: PR #641, merged 2026-04-17. Buyer: Platform engineers + enterprise security/compliance. Headline: 'Give your agents a Git history — without touching a terminal.' Objections covered: 'Why not GitHub?' + 'Cloudflare Artifacts is beta.' Blocking: Social Media Brand launch thread. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * PMM: update EC2 SSH launch brief — social copy APPROVED, TTS audio file added as blocker Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * PMM: update ecosystem-watch — verify LangGraph PRs still OPEN, log PRs #1702/#1730/#1731 Confirmed via gh CLI (GH_TOKEN restored): langchain-ai/langgraph PRs #6645, #7113, #7205 still OPEN as of 2026-04-23T17:38Z. A2A live-today positioning vs LangGraph in-progress remains accurate. Logged PR #1731 (sweepPhantomBusy), PR #1730 (45-min gh-token refresh daemon fixing 60-min 401 in long sessions), and PR #1702 (SSH-backed file writes for SaaS — P1 regression fix). Blog post for #1702 at docs/marketing/blog/2026-04-23-saas-file-api-fix.md. Co-Authored-By: Claude PMM <noreply@anthropic.com> * docs(marketing): add PR #1702 release note + PR #1686 positioning brief PR #1702 (SSH-backed file writes for SaaS): blog post covers fix, compute model detection, EIC-based remote write path. Ships same-day after merge. PR #1686 (Tool Trace + Platform Instructions): full positioning brief — buyer matrix, value props, competitive angle vs Langfuse/Helicone/OPA, objection handlers, cannibalization assessment (LOW). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs(mmm): add Phase 34 positioning one-pager + messaging matrix - phase34-positioning.md: one-pager with positioning statement, audience matrix, problem/solution, competitive differentiators, and proof points for press kit use - phase34-messaging-matrix.md: 3 candidate taglines (production-grade, observability, aspirational) + full 4-feature messaging matrix (Partner API Keys, Tool Trace, Platform Instructions, SaaS Fed v2) - SaaS Federation v2 flagged as content gap — no PM brief exists; community copy blocked pending PM confirmation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Molecule AI PMM <pmm@agents.moleculesai.app> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Apr 23, 2026
This was referenced Apr 23, 2026
molecule-ai Bot
pushed a commit
that referenced
this pull request
Apr 24, 2026
…al copy Phase 34 launched 2026-04-23 with PR #1686: - Tool Trace: tool_call trace in every A2A response metadata - Platform Instructions: global/workspace governance at system prompt level Adds: - Social copy: 5 X variants + 3 LinkedIn variants - Screencast TTS script (already written, minor copy edit) - Publishing schedule and UTMs coordinated with Marketing Lead Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
molecule-ai Bot
pushed a commit
that referenced
this pull request
Apr 24, 2026
…al copy Phase 34 launched 2026-04-23 with PR #1686: - Tool Trace: tool_call trace in every A2A response metadata - Platform Instructions: global/workspace governance at system prompt level Adds: - Social copy: 5 X variants + 3 LinkedIn variants - Screencast TTS script (already written, minor copy edit) - Publishing schedule and UTMs coordinated with Marketing Lead Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
HongmingWang-Rabbit
pushed a commit
that referenced
this pull request
Jun 12, 2026
…rd (#1695) Co-authored-by: agent-dev-a <agent-dev-a@agents.moleculesai.app> Co-committed-by: agent-dev-a <agent-dev-a@agents.moleculesai.app>
HongmingWang-Rabbit
pushed a commit
that referenced
this pull request
Jun 12, 2026
…1701) from feat/1686-display-unavailable into main
HongmingWang-Rabbit
pushed a commit
that referenced
this pull request
Jun 12, 2026
…1705) from feat/1686-container-config-tab into main
HongmingWang-Rabbit
pushed a commit
that referenced
this pull request
Jun 12, 2026
… from feat/1686-display-status-contract into main
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two platform-level observability + control features. Both passed comprehensive code review with all blockers + high-severity issues fixed.
1. Tool Trace
Every A2A response now includes a
tool_tracelist (tool name, input, output_preview) inMessage.metadata, stored in newactivity_logs.tool_traceJSONB column. Pairs start/end events viarun_idso parallel tool calls work correctly. Capped at 200 entries to prevent runaway-loop bloat.2. Platform Instructions
Configurable rules with global/workspace scope, fetched at workspace startup and prepended to system prompt. CRUD API +
/workspaces/:id/instructions/resolve(gated by wsAuth — no cross-workspace enumeration). CHECK constraints enforce 8KB content cap to prevent token-budget DoS. Team scope reserved in schema for future migration.Review fixes applied
Files
🤖 Generated with Claude Code