Skip to content

Add read-only agent observe skill - #173

Closed
sethkarten wants to merge 2 commits into
mainfrom
feature/agent-observe
Closed

Add read-only agent observe skill#173
sethkarten wants to merge 2 commits into
mainfrom
feature/agent-observe

Conversation

@sethkarten

@sethkarten sethkarten commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a bundled agent-observe Python skill for read-only observation of active daemon sessions
  • expose daemon-backed host handlers for list_agents, get_agent, and bounded recent_messages
  • keep the observe surface read-only and hide the skill outside daemon-backed sessions

Safety

  • no prompt/steer/clear/kill/rename mutation methods are exposed through the skill
  • recent messages are bounded by count and per-message character limits
  • tool-call previews include tool names, not arguments

Validation

  • npx vitest --run packages/coding-agent/test/agent-observe.test.ts packages/coding-agent/test/suite/agent-session-observe.test.ts packages/coding-agent/test/kernel-agent-observe-skill.test.ts packages/coding-agent/test/builtin-skills.test.ts packages/coding-agent/test/daemon-mode.test.ts
  • npx tsgo --noEmit --pretty false
  • npm run check
  • npm run test -- --run

Note

Add read-only agent-observe skill for inspecting active daemon sessions

  • Adds a new Python skill (agent_observe) exposing list_agents, get_agent, and recent_messages functions that route through the host bridge to query active daemon sessions.
  • Implements the TypeScript host-side handlers in agent-observe.ts, including input validation, limit/maxChars clamping (1–50 and 80–2000), and message preview construction that exposes tool call names but not arguments.
  • Wires an AgentObserveController into AgentSession and AgentDaemon so both top-level sessions and RLM subagents can serve observe requests; the skill is hidden from the model when no controller is present.
  • Adds tests covering preview generation, host bridge routing, Python-side type validation, and skill bundling.

Macroscope summarized e7bba05.


Note

Medium Risk
Opens a new read-only channel for agents to read truncated content from other daemon sessions in the same process; mitigated by no mutation APIs and bounded previews, but still a cross-session information leak surface for orchestration.

Overview
Introduces a read-only cross-session observation path for agents running under the local daemon. A new bundled agent-observe Python skill (agent_observe.list_agents, get_agent, recent_messages) forwards to TypeScript host handlers; the daemon implements AgentObserveController over all live runtimes (top-level and RLM subagents).

AgentSession accepts an optional agentObserveController, wires agent_observe.* kernel host requests, and hides the skill from the system prompt when no controller is configured (local-only sessions). Message previews are bounded (limit 1–50, max_chars 80–2000) and assistant tool previews expose names only, not arguments.

Tests cover preview helpers, session routing, kernel bridge, bundled skill discovery, and controller forwarding through session services.

Reviewed by Cursor Bugbot for commit e7bba05. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment on lines +1 to +4
[project]
name = "agent-observe"
version = "0.1.0"
description = "Read-only Prime Agent session observation skill"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High agent-observe/pyproject.toml:1

The pyproject.toml is missing the [build-system] section required for editable installation. When uv pip install --editable falls back to setuptools (which happens without an explicit build-system), the src/agent_observe/ layout may not be discovered correctly, causing the skill to fail to install and be silently unavailable at runtime.

+[build-system]
+requires = ["hatchling"]
+build-backend = "hatchling.build"
+
+[tool.hatch.build.targets.wheel]
+packages = ["src/agent_observe"]
+
 [project]
 name = "agent-observe"
 version = "0.1.0"
 description = "Read-only Prime Agent session observation skill"
 requires-python = ">=3.10"
 
 [tool.prime_agent.skill]
 import = "agent_observe"
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @packages/coding-agent/skills/agent-observe/pyproject.toml around lines 1-4:

The `pyproject.toml` is missing the `[build-system]` section required for editable installation. When `uv pip install --editable` falls back to setuptools (which happens without an explicit build-system), the `src/agent_observe/` layout may not be discovered correctly, causing the skill to fail to install and be silently unavailable at runtime.

@sethkarten
sethkarten marked this pull request as ready for review June 16, 2026 18:35

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e7bba05. Configure here.

return this.addRuntime(runtime, command.name);
const state = await this.addRuntime(runtime, command.name);
stateRef = state;
return state;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Observe stateRef set too late

Medium Severity

The daemon passes an agentObserveController into session creation before the corresponding ActiveSessionState exists, and only assigns stateRef after addRuntime finishes. Any agent_observe host call during that window (including background IPython prewarm or bindExtensions) hits requireCurrentState and errors with “Agent observe state is not ready for this session yet”.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e7bba05. Configure here.

@sethkarten

Copy link
Copy Markdown
Contributor Author

Superseded by #207, which combines read-only agent observation with safe daemon-backed agent messaging into one user orchestrator PR.

@sethkarten

Copy link
Copy Markdown
Contributor Author

Closing in favor of #207, which combines this read-only observe work with daemon-backed messaging and orchestration heartbeat support.

@sethkarten sethkarten closed this Jun 18, 2026
@sethkarten
sethkarten deleted the feature/agent-observe branch June 18, 2026 21:37
zhengr pushed a commit to zhengr/prime-agent that referenced this pull request Aug 8, 2026
zhengr pushed a commit to zhengr/prime-agent that referenced this pull request Aug 8, 2026
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