Skip to main content

Module subagent

Module subagent 

Source
Expand description

The subagent a tool call runs for, so its ballot binds its own session rather than its parent’s. Claude Code hands a hook the subagent’s agent_id and the call’s tool_use_id, but gives the command it runs no variable that names the agent. The hook leaves the call under the runtime directory, and the ljos the command runs, or the MCP server the call reaches, takes it back once. A shell call stays behind as taken until it expires, so the same line run again inside the call binds the session its first run bound and is refused as cast.

A shell call is kept with the hook’s ancestors, and only a process that runs under the nearest of them still alive takes it: the harness that ran the hook runs the command too. The files are not signed. Anything running as the same user can still write one naming a live ancestor of a later ljos; the check stops a record left by hand, or by a process in another tree, from naming a session.

Structs§

Taken
The call a hook saw run this process’s ljos line, as this process took it.

Functions§

claim_command
The agent of the ljos line this process runs, when a hook saw it under session. The newest call whose line is this argv is taken, so no other process takes it too and a parent’s call is never answered by an older one its subagent left. An empty agent is the parent’s.
claim_mcp_call
The session and subagent of a Claude Code MCP call, by the tool use id its _meta carries, when its hook saw a subagent make it. Taken once.
claim_recent_mcp_session
The session of a recent MCP hook call when _meta carried no id or toolUseId, taken once when only one conversation’s hook call is waiting in the last [MCP_CALL_TTL_MS].
claim_unsessioned_command
The session and agent of the ljos line this process runs, when this process names no session of its own: a seat whose runner stamps no id in the shell. The hook saw the line under its session, so every session’s calls are read, and the newest whose line is this argv is taken once. An empty agent is the parent’s.
is_seat_mcp_tool
Whether tool is one of the seat’s MCP tools, mcp__SERVER__ljos_NAME, and SERVER is a key whose command is the seat’s own MCP server. The name shape alone is not enough. An unknown or unreadable config is not a match.
mcp_prefixed_tool
mcp__SERVER__NAME, split on the last __ so SERVER may contain __. None when the name is not that shape.
note_hook_call
Leave what a hook payload says about its tool call. On PreToolUse, each ljos line of a shell call is kept for the process that runs it, and a subagent’s mcp__SERVER__ljos_NAME call is kept for the server whether or not SERVER is a configured key. On PostToolUse what the call did not take is dropped. The payload’s agent is this hook process’s own. Returns whether the call is a PreToolUse on a confirmed seat server: the server judges that call, so the hook has nothing more to say.
payload_names_mcp_tool
An MCP tool call. Shell-only checks, such as a missing working directory, do not apply to it.
peek_recent_mcp_session
claim_recent_mcp_session without taking the record, for a caller that only wants to know whether the record names it.
runs_as_ljos
Whether this process is the ljos command line, rather than the MCP server or a test.
taken_harness
The harness of the call this process took, once it has looked for one.