roboto.ai.agent_thread.agent_thread_goal_view#
SDK wrapper that resolves an AgentThreadGoalRecord against the
parent thread’s message stream.
AgentThreadGoalView is the read shape AgentThread.goals returns. It
delegates field reads to the underlying record and adds three resolved
properties:
achieve_tool_use— the rawAgentToolUseContentfor the achieve-tool invocation associated with the goal.achieve_tool_result— the matchingAgentToolResultContent, when one was persisted.result— the typed, per-goal-typeGoalResultparsed from the tool_use input.
All three resolve lazily by scanning the parent thread’s messages
list for the achieve_tool_use_id stored on the record. A single
internal pass locates the tool_use / tool_result pair and is shared by
all three accessors, so reading goal.achieve_tool_use,
goal.achieve_tool_result, and goal.result in sequence does the
same work as reading any one of them. The pair is cached on the wrapper
after the first lookup, keyed on the messages-list identity, so
repeated reads on the same snapshot are constant-time after the first.
Module Contents#
- class roboto.ai.agent_thread.agent_thread_goal_view.AgentThreadGoalView(record, messages)#
SDK-side wrapper around an
AgentThreadGoalRecord.Holds a back-reference to a messages list (the parent thread’s full message history) so the achieve-tool invocation can be located via
achieve_tool_use_idwithout forcing the caller to do the lookup by hand.The wrapper is value-like: instantiating it does not copy the underlying record. Callers should not mutate it; mutations on the parent thread (via
run/refresh) are visible through the wrapper’s resolved properties because the messages list is shared.- Parameters:
record (roboto.ai.agent_thread.record.AgentThreadGoalRecord)
messages (list[roboto.ai.agent_thread.record.AgentMessage])
- property achieve_tool_result: roboto.ai.agent_thread.record.AgentToolResultContent | None#
The matching tool-result block for
achieve_tool_use, if the runner persisted one before the turn terminated.For a FAILED goal whose last attempt errored mid-flight (or whose tool_result chunk never landed), this returns
Noneeven whenachieve_tool_useis non-null.- Return type:
- property achieve_tool_use: roboto.ai.agent_thread.record.AgentToolUseContent | None#
The achieve-tool invocation the LLM submitted for this goal.
Returns
Nonewhenachieve_tool_use_idisNone(no attempt has been recorded) or when no matching block is present in the thread’s messages — the latter can happen if the caller is holding a thread snapshot that pre-dates the achieve-tool being persisted. In that case, a refresh of the thread should bring the block into view.- Return type:
- property achieve_tool_use_id: str | None#
tool_use_idof the achieve-tool invocation associated with this goal — seeAgentThreadGoalRecord.achieve_tool_use_idfor the per-status semantics.- Return type:
str | None
- property concluded_at: datetime.datetime | None#
Timestamp when the goal reached a terminal state, or
Nonewhile still PENDING.- Return type:
datetime.datetime | None
- property created: datetime.datetime#
Timestamp when the goal was registered.
- Return type:
datetime.datetime
- property goal_data: dict[str, Any]#
The original goal-declaration payload. Use
to_agent_goal()to re-hydrate into the typedAgentGoalmodel.- Return type:
dict[str, Any]
- property goal_type: str#
Discriminator selecting which
AgentGoalmodel the goal was declared as. Equivalent toself.record.goal_type.- Return type:
str
- property message_sequence_num: int#
Index of the user-role message that declared this goal.
- Return type:
int
- property record: roboto.ai.agent_thread.record.AgentThreadGoalRecord#
The underlying wire record. Useful for callers that want the unwrapped pydantic shape (e.g. for JSON serialization).
- Return type:
- property result: roboto.ai.goals.results.GoalResult | None#
Typed, per-goal-type result for the achieve-tool invocation.
Returns
Nonewhen no terminal achieve-tool invocation is available (PENDING goal, or FAILED with no attempted invocation), when the matchingtool_usecannot be located in the thread’s messages, or when the persisted input is malformed enough to fail validation against the achieve-input model. In all three cases callers can still inspectachieve_tool_use/achieve_tool_resultdirectly for debugging.The returned object is one of the concrete subclasses of
GoalResult(e.g.DatasetSummaryGoalResult), so callers canisinstance-dispatch or simply read the typed fields. The status field reflects the goal’s terminal status, so the same accessor works for both ACHIEVED and FAILED outcomes.- Return type:
roboto.ai.goals.results.GoalResult | None
- property status: roboto.ai.agent_thread.record.AgentGoalStatus#
Current lifecycle state of the goal.
- Return type:
- to_agent_goal()#
Re-hydrate the goal declaration into its typed
AgentGoalmodel. Delegates toAgentThreadGoalRecord.to_agent_goal().- Return type:
roboto.ai.goals.types.AgentGoal