MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / LocalAgentTaskState

Class LocalAgentTaskState

src/tasks/local_agent.py:36–93  ·  view source on GitHub ↗

Runtime state for a background ``local_agent`` task. Field accounting (chapter-correct full set; refactoring plan WI-2.3 now lands what WI-1.5 stubbed): Stays from base: id, type, status, description, start_time, output_file (now the sidechain JSONL path), output_offset

Source from the content-addressed store, hash-verified

34
35@dataclass(kw_only=True)
36class LocalAgentTaskState(TaskStateBase):
37 """Runtime state for a background ``local_agent`` task.
38
39 Field accounting (chapter-correct full set; refactoring plan WI-2.3
40 now lands what WI-1.5 stubbed):
41
42 Stays from base:
43 id, type, status, description, start_time, output_file (now
44 the sidechain JSONL path), output_offset, notified, tool_use_id,
45 end_time, total_paused_seconds.
46
47 Extension fields:
48 agent_id — same string as ``id``; kept as a separate
49 field for chapter-fidelity with TS.
50 agent_type — agent definition's ``agent_type``
51 (general-purpose, worker, fork, ...).
52 prompt — the user-supplied prompt text.
53 selected_agent — the resolved AgentDefinition; loose-typed
54 to avoid an import cycle.
55 model — optional per-spawn model override.
56 abort_event — asyncio.Event for cooperative kill.
57 pending_messages — Chunk D / WI-3.3 inbox; SendMessage
58 queues here for delivery at next tool
59 round.
60 is_backgrounded — was this spawned async or promoted later?
61 retain — UI is "holding" this task; blocks
62 eviction (Chunk D / WI-3.4).
63 disk_loaded — bootstrap has read the JSONL transcript
64 and merged it into ``messages``.
65 evict_after — Chunk D / WI-3.4 eviction grace deadline.
66 progress — live ``AgentProgress`` snapshot.
67 last_reported_* — delta-tracking for SDK progress events.
68 result_text / error — final output container.
69 """
70
71 type: Literal["local_agent"] = "local_agent" # type: ignore[assignment]
72 agent_id: str = ""
73 agent_type: str = ""
74 prompt: str = ""
75 selected_agent: Any = None # AgentDefinition; loose to avoid cycles.
76 model: str | None = None
77 abort_event: asyncio.Event | None = field(default=None, repr=False, compare=False)
78 pending_messages: list[str] = field(default_factory=list)
79 is_backgrounded: bool = True
80 retain: bool = False
81 disk_loaded: bool = False
82 evict_after: float | None = None
83 progress: "AgentProgress | None" = None
84 last_reported_tool_count: int = 0
85 last_reported_token_count: int = 0
86 result_text: str = ""
87 error: str | None = None
88 # Chunk F / WI-7.4 race guard. Set True by the auto-resume claim
89 # mutator when this terminal state is being re-spawned; concurrent
90 # SendMessage callers see the flag and back off to queueing the
91 # message onto the resumed agent's pending_messages instead.
92 # Reset to False on the fresh state ``register_async_agent`` upserts.
93 is_resuming: bool = False

Callers 1

register_async_agentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected