Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/agent_env/agents/agents/browser-use/a2a_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#: How much of the turn's deadline browser-use's own run leaves: its forced delivery when it runs out, and its stop.
DELIVERY_SECONDS = 100
STOP_SECONDS = 5
#: The native trajectory: browser-use's messages, each turn's when it ends.
TRAJECTORY_FORMAT = "browser-use-messages/1"
#: browser-use and its browser daemon report usage to their makers unless told not to.
_PRIVATE_ENV = {"ANONYMIZED_TELEMETRY": "false", "BH_TELEMETRY": "0"}

Expand Down Expand Up @@ -65,7 +67,8 @@ class BrowserUseConfig(AgentConfig):
extensions=(
MCP_CONFIG_V1,
CDP_CONFIG_V1,
enable(TRAJECTORY_V1, live=False, description="browser-use's messages, each turn's when it ends."),
enable(TRAJECTORY_V1, live=False, native=TRAJECTORY_FORMAT,
description="browser-use's messages, each turn's when it ends."),
),
)
class BrowserUseAgent(AgentEnvAgent):
Expand Down Expand Up @@ -103,7 +106,7 @@ async def run(self, request: TaskRequest[BrowserUseConfig]) -> TaskResult:
"historyFile": str(HOME / "sessions" / f"{session}-{hashlib.sha256(model.encode()).hexdigest()[:8]}.json"),
}
(HOME / "sessions").mkdir(parents=True, exist_ok=True)
request.trajectory.set_format("browser-use-messages/1")
request.trajectory.set_format(TRAJECTORY_FORMAT)

process = await asyncio.create_subprocess_exec(
*self.command,
Expand Down
6 changes: 3 additions & 3 deletions src/agent_env/agents/agents/browser-use/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The image installs the newest agentenv-framework-protocol at or above this floor; a release doesn't pin it, so the
# image is built again only when this folder changes. The floor is the first whose extension routes take the agent's
# control token; raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.582
# image is built again only when this folder changes. The floor is the first that takes the native trajectory format
# the agent declares (enable(TRAJECTORY_V1, native=...)); raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.588
8 changes: 6 additions & 2 deletions src/agent_env/agents/agents/claude-code/a2a_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
HARNESS = "claude-code"
# The versioned format of the stream-json events a turn's trajectory holds.
TRAJECTORY_FORMAT = "claude-code-stream-json/1"
# A context read's format: the records of the CLI's session file, the conversation so far. Never the native format.
SESSION_TRAJECTORY_FORMAT = "claude-code-session/1"
# The CLI loads skills from <state>/skills/<name>/SKILL.md.
SKILLS_DIR = CLAUDE_STATE_DIR / "skills"
# FileParts are written here, one folder per task, and their paths appended to the prompt: the CLI reads a path in
Expand Down Expand Up @@ -401,7 +403,7 @@ async def _turns_stop_with_the_server(app: Starlette) -> AsyncIterator[None]:
config_description="Set or read agent configuration such as model, role, and allowed tools.",
lifespan=_turns_stop_with_the_server,
extensions=(
enable(TRAJECTORY_V1, live=True, description=(
enable(TRAJECTORY_V1, live=True, native=TRAJECTORY_FORMAT, description=(
"Retrieve a task's Claude Code stream-json trajectory, also while it runs, "
"or a context's cumulative trajectory including a live run.")),
enable(MCP_CONFIG_V1, description="Register MCP servers the Claude Code CLI should connect to."),
Expand Down Expand Up @@ -538,6 +540,7 @@ async def _context_trajectory(self, context_id: str) -> dict[str, Any]:
raise HTTPException(status_code=404, detail=f"No transcript yet for context_id '{context_id}'")
return {
"trajectory": trajectory,
"format": SESSION_TRAJECTORY_FORMAT,
"session_lines": session_lines,
"is_live": context_id in self._active_contexts,
"session_id": session_id,
Expand All @@ -553,7 +556,8 @@ async def get_context_trajectory(self, request: ContextTrajectoryRequest) -> dic
async def upload_context_trajectory(self, request: ContextObjectTrajectoryRequest) -> dict[str, Any]:
trajectory = (await self._context_trajectory(request.context_id))["trajectory"]
body = json.dumps(trajectory, separators=(",", ":"), default=str).encode()
return {"objects": {"trajectory": _answer(await upload(request.objects.trajectory, body))}}
return {"objects": {"trajectory": _answer(await upload(request.objects.trajectory, body))},
"format": SESSION_TRAJECTORY_FORMAT}

@extension(SKILL_CONFIG_V1.add.inline)
async def add_inline_skill(self, request: InlineSkillRequest) -> SkillAddResponse:
Expand Down
6 changes: 3 additions & 3 deletions src/agent_env/agents/agents/claude-code/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The image installs the newest agentenv-framework-protocol at or above this floor; a release doesn't pin it, so the
# image is built again only when this folder changes. The floor is the first whose extension routes take the agent's
# control token; raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.582
# image is built again only when this folder changes. The floor is the first that takes the native trajectory format
# the agent declares (enable(TRAJECTORY_V1, native=...)); raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.588
5 changes: 4 additions & 1 deletion src/agent_env/agents/agents/codex/a2a_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ async def _stage_granted_workspace(source: ReadObject | None) -> Path | None:
enable(
TRAJECTORY_V1,
live=True,
native=TRAJECTORY_FORMAT,
description="Retrieve a task's Codex --json trajectory, also while it runs.",
),
enable(
Expand Down Expand Up @@ -806,6 +807,7 @@ async def _context_trajectory(self, context_id: str) -> dict[str, Any]:
)
return {
"trajectory": trajectory,
"format": TRAJECTORY_FORMAT,
"is_live": is_live,
"session_id": self.session_ref_for_context(context_id),
"harness": HARNESS,
Expand All @@ -821,7 +823,8 @@ async def get_context_trajectory(self, request: ContextTrajectoryRequest) -> dic
async def upload_context_trajectory(self, request: ContextObjectTrajectoryRequest) -> dict[str, Any]:
trajectory = (await self._context_trajectory(request.context_id))["trajectory"]
body = json.dumps(trajectory, separators=(",", ":"), default=str).encode()
return {"objects": {"trajectory": _answer(await upload(request.objects.trajectory, body))}}
return {"objects": {"trajectory": _answer(await upload(request.objects.trajectory, body))},
"format": TRAJECTORY_FORMAT}

@extension(SNAPSHOT_V1.save)
async def save_snapshot(self, request: ObjectSnapshotSaveRequest) -> dict[str, Any]:
Expand Down
6 changes: 3 additions & 3 deletions src/agent_env/agents/agents/codex/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The image installs the newest agentenv-framework-protocol at or above this floor; a release doesn't pin it, so the
# image is built again only when this folder changes. The floor is the first whose extension routes take the agent's
# control token; raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.582
# image is built again only when this folder changes. The floor is the first that takes the native trajectory format
# the agent declares (enable(TRAJECTORY_V1, native=...)); raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.588
tomli-w==1.2.0
# The CA certificates an installed agent's CLI trusts on a target that has none of its own; unpinned, so each build
# takes the newest.
Expand Down
1 change: 1 addition & 0 deletions src/agent_env/agents/agents/gemini/a2a_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ async def _vertex_openai_bridge(
enable(
TRAJECTORY_V1,
live=True,
native=TRAJECTORY_FORMAT,
description="Retrieve a task's Gemini stream-json trajectory, also while it runs.",
),
enable(MCP_CONFIG_V1, description="Register MCP servers the Gemini CLI should connect to."),
Expand Down
6 changes: 3 additions & 3 deletions src/agent_env/agents/agents/gemini/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The image installs the newest agentenv-framework-protocol at or above this floor; a release doesn't pin it, so the
# image is built again only when this folder changes. The floor is the first whose extension routes take the agent's
# control token; raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.582
# image is built again only when this folder changes. The floor is the first that takes the native trajectory format
# the agent declares (enable(TRAJECTORY_V1, native=...)); raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.588
2 changes: 1 addition & 1 deletion src/agent_env/agents/agents/hermes/a2a_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def _tar(*args: str) -> None:
config=HermesConfig,
extensions=(
MCP_CONFIG_V1,
enable(TRAJECTORY_V1, live=True),
enable(TRAJECTORY_V1, live=True, native=TRAJECTORY_FORMAT),
enable(ATTRIBUTION_PROBE_V1),
# SDK default: Hermes reaches the task's other agents through the SDK's peer_agents MCP tools.
PEER_AGENTS_V1,
Expand Down
6 changes: 3 additions & 3 deletions src/agent_env/agents/agents/hermes/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The image installs the newest agentenv-framework-protocol at or above this floor; a release doesn't pin it, so the
# image is built again only when this folder changes. The floor is the first whose extension routes take the agent's
# control token; raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.582
# image is built again only when this folder changes. The floor is the first that takes the native trajectory format
# the agent declares (enable(TRAJECTORY_V1, native=...)); raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.588
jsonschema>=4.18,<5
2 changes: 1 addition & 1 deletion src/agent_env/agents/agents/letta-code/a2a_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ async def lifespan(app: Starlette):
config=LettaCodeConfig,
extensions=(
MCP_CONFIG_V1,
enable(TRAJECTORY_V1, live=True),
enable(TRAJECTORY_V1, live=True, native=TRAJECTORY_FORMAT),
enable(ATTRIBUTION_PROBE_V1),
enable(
INSTALL_V1,
Expand Down
6 changes: 3 additions & 3 deletions src/agent_env/agents/agents/letta-code/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The image installs the newest agentenv-framework-protocol at or above this floor; a release doesn't pin it, so the
# image is built again only when this folder changes. The floor is the first whose extension routes take the agent's
# control token; raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.582
# image is built again only when this folder changes. The floor is the first that takes the native trajectory format
# the agent declares (enable(TRAJECTORY_V1, native=...)); raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.588
jsonschema>=4.18,<5
aiohttp>=3.9,<4
2 changes: 1 addition & 1 deletion src/agent_env/agents/agents/opencode/a2a_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def memory_mb(cgroup_limit: Path = Path("/sys/fs/cgroup/memory.max")) -> int:
config=OpenCodeConfig,
extensions=(
MCP_CONFIG_V1,
enable(TRAJECTORY_V1, live=True),
enable(TRAJECTORY_V1, live=True, native=TRAJECTORY_FORMAT),
enable(ATTRIBUTION_PROBE_V1),
enable(
INSTALL_V1,
Expand Down
6 changes: 3 additions & 3 deletions src/agent_env/agents/agents/opencode/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The image installs the newest agentenv-framework-protocol at or above this floor; a release doesn't pin it, so the
# image is built again only when this folder changes. The floor is the first whose extension routes take the agent's
# control token; raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.582
# image is built again only when this folder changes. The floor is the first that takes the native trajectory format
# the agent declares (enable(TRAJECTORY_V1, native=...)); raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.588
jsonschema>=4.18,<5
3 changes: 2 additions & 1 deletion src/agent_env/agents/agents/openhands/openhands_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ def _stage_conversation(archive: Path, conversations_dir: Path, target_id: str,
lifespan=_turns_stop_with_the_server,
extensions=(
MCP_CONFIG_V1,
enable(TRAJECTORY_V1, live=True, description="The task's OpenHands SDK events, also while it runs."),
enable(TRAJECTORY_V1, live=True, native=TRAJECTORY_FORMAT,
description="The task's OpenHands SDK events, also while it runs."),
enable(
SNAPSHOT_V1,
description=(
Expand Down
6 changes: 3 additions & 3 deletions src/agent_env/agents/agents/openhands/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The image installs the newest agentenv-framework-protocol at or above this floor; a release doesn't pin it, so the
# image is built again only when this folder changes. The floor is the first whose extension routes take the agent's
# control token; raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.582
# image is built again only when this folder changes. The floor is the first that takes the native trajectory format
# the agent declares (enable(TRAJECTORY_V1, native=...)); raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.588
openhands-sdk==1.58.2
openhands-tools==1.58.2
3 changes: 2 additions & 1 deletion src/agent_env/agents/agents/pi/pi_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ def _unpack(archive: Path, directory: Path) -> None:
config_description="Configure the pi runtime: model, effort, system prompt and tool allowlist.",
extensions=(
MCP_CONFIG_V1,
enable(TRAJECTORY_V1, description="The pi JSON-mode event stream of a completed task."),
enable(TRAJECTORY_V1, native=TRAJECTORY_FORMAT,
description="The pi JSON-mode event stream of a completed task."),
enable(
SNAPSHOT_V1,
description=(
Expand Down
6 changes: 3 additions & 3 deletions src/agent_env/agents/agents/pi/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The image installs the newest agentenv-framework-protocol at or above this floor; a release doesn't pin it, so the
# image is built again only when this folder changes. The floor is the first whose extension routes take the agent's
# control token; raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.582
# image is built again only when this folder changes. The floor is the first that takes the native trajectory format
# the agent declares (enable(TRAJECTORY_V1, native=...)); raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.588
6 changes: 3 additions & 3 deletions src/agent_env/agents/agents/proxy/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The image installs the newest agentenv-framework-protocol at or above this floor; a release doesn't pin it, so the
# image is built again only when this folder changes. The floor is the first whose extension routes take the agent's
# control token; raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.582
# image is built again only when this folder changes. The floor is the first that takes the native trajectory format
# the agent declares (enable(TRAJECTORY_V1, native=...)); raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.588
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ def _stage_conversation(
lifespan=_turns_stop_with_the_server,
extensions=(
MCP_CONFIG_V1,
enable(TRAJECTORY_V1, live=True, description="The task's Pydantic AI messages, also while it runs."),
enable(TRAJECTORY_V1, live=True, native=TRAJECTORY_FORMAT,
description="The task's Pydantic AI messages, also while it runs."),
enable(
SNAPSHOT_V1,
description=(
Expand Down
6 changes: 3 additions & 3 deletions src/agent_env/agents/agents/pydantic-ai/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The image installs the newest agentenv-framework-protocol at or above this floor; a release doesn't pin it, so the
# image is built again only when this folder changes. The floor is the first whose extension routes take the agent's
# control token; raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.582
# image is built again only when this folder changes. The floor is the first that takes the native trajectory format
# the agent declares (enable(TRAJECTORY_V1, native=...)); raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.588
pydantic-ai-slim[mcp,openai]==2.61.0
pydantic-ai-harness[coder,skills]==0.61.0
14 changes: 12 additions & 2 deletions tst/integration/agent/proxy_container_install_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""The proxy's folder installed into a running container by its own install.sh, as install_agent installs it there. It
brings its own Python and serves; its bash runs commands with bash, or with sh in a container that has only sh (Alpine,
musl), and says which. The container installs this checkout's protocol, so the test covers the code beside it, and its
extension routes take the control token the install was handed, as install_agent hands it."""
musl), and says which. The container installs this checkout's protocol, so the test covers the code beside it; its
extension routes take the control token the install was handed, as install_agent hands it; and its card offers its
native trajectory format, which its reads name, refusing any other."""

import os
import shutil
Expand All @@ -23,6 +24,7 @@
AGENT_DIR = Path(agent_env.__file__).parent / "agents" / "agents" / "proxy"
PROTOCOL_DIR = Path(agent_env.__file__).parents[2] / "packages" / "agentenv-protocol"
PORT = 8000
NATIVE = "agentenv-proxy/v1"
TOKEN = "t" * 32
CONTROL_TOKEN = "c" * 32

Expand Down Expand Up @@ -57,17 +59,25 @@ def test_installed_into_a_container_the_proxy_serves_and_its_bash_runs_the_shell
base_url = f"http://{_published(name)}"
with httpx.Client(base_url=base_url, timeout=30, headers=control_token_headers(CONTROL_TOKEN)) as client:
_serving(client)
card = client.get("/.well-known/agent.json").json()
assert httpx.post(f"{base_url}/ext/proxy/claim", json={"token": TOKEN}, timeout=30).status_code == 401
assert client.post("/ext/proxy/claim", json={"token": TOKEN}).status_code == 200
task_id = _send(client, "go")
tools = _proxy(client, "tools", task_id=task_id).json()["tools"]
result = _done(client, task_id, {"kind": "bash", "command": "echo $0; echo out"})
page = client.post("/ext/trajectory", json={"task_id": task_id, "after": 0, "format": NATIVE})
refused = client.post("/ext/trajectory", json={"task_id": task_id, "after": 0, "format": "atif/1"})

assert [tool["name"] for tool in tools] == ["bash"]
assert tools[0]["description"].startswith(
"Run a bash command where" if shell == "bash" else "Run a command where the agent works, as its user, in its "
"folder, with POSIX sh: this place has no bash")
assert (result["exit_code"], result["stdout"]) == (0, f"{shell}\nout\n")
(trajectory,) = [e for e in card["capabilities"]["extensions"] if e["uri"] == "urn:agentenv:trajectory/v1"]
assert {k: trajectory["params"][k] for k in ("formats", "native", "default")} == {
"formats": [NATIVE], "native": NATIVE, "default": NATIVE}
assert (page.status_code, page.json()["format"]) == (200, NATIVE)
assert (refused.status_code, refused.json()["error"]["code"]) == (400, "format_not_offered")


def _published(container: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion tst/unit/agents/claude_code/test_image_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_the_image_installs_the_protocol_alone_from_its_requirements():
requirements = [line for line in (AGENT_DIR / "requirements.txt").read_text().splitlines()
if line and not line.startswith("#")]

assert requirements == ["agentenv-framework-protocol[agent]>=0.1.582"]
assert requirements == ["agentenv-framework-protocol[agent]>=0.1.588"]


def test_the_image_gives_the_model_node_alone_from_a_pinned_image():
Expand Down
3 changes: 2 additions & 1 deletion tst/unit/agents/claude_code/test_object_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def test_a_context_trajectory_is_uploaded_through_its_grant(monkeypatch, tmp_pat

body = store.objects["traj/ctx-1.json"]
assert body == json.dumps([{"type": "assistant", "message": message, "session_id": "s-1"}], separators=(",", ":")).encode()
assert result == {"objects": {"trajectory": {"size_bytes": len(body), "sha256": hashlib.sha256(body).hexdigest()}}}
assert result == {"objects": {"trajectory": {"size_bytes": len(body), "sha256": hashlib.sha256(body).hexdigest()}},
"format": a2a_server.SESSION_TRAJECTORY_FORMAT}


# ── snapshot ─────────────────────────────────────────────────────────────────────
Expand Down
1 change: 1 addition & 0 deletions tst/unit/agents/claude_code/test_partial_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def test_context_trajectory_endpoint_reports_complete_live_session(monkeypatch,
"session_id": "session-1",
}
],
"format": a2a_server.SESSION_TRAJECTORY_FORMAT,
"session_lines": 2,
"is_live": True,
"session_id": "session-1",
Expand Down
Loading
Loading