Skip to content
Merged
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
28 changes: 2 additions & 26 deletions src/truefoundry_gateway_sdk/agents/prepared_turn.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,19 +353,7 @@ def _must_get_turn(self) -> Turn:

def _adopt_turn_from_api(self, turn: RawTurn) -> None:
"""Build the inner Turn from create_turn / get_turn response data."""
self._turn = Turn(
RawTurn(
id=turn.id,
session_id=turn.session_id,
previous_turn_id=turn.previous_turn_id,
input=turn.input if turn.input is not None else self._input, # type: ignore[arg-type]
state=turn.state,
created_by_subject=turn.created_by_subject,
created_at=turn.created_at,
),
self._session,
self._client,
)
self._turn = Turn(turn, self._session, self._client)

@chiragjn chiragjn Aug 25, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same comment as TS, do we need to copy turn if Turn mutates it in anyway?

same for self._session

--

same comment for async

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same comment as TS, do we need to copy turn if Turn mutates it in anyway?

same for self._session

  • Turn (src/truefoundry_gateway_sdk/agents/turn.py) only reads fields onto self, later updates reassign self._state, never the passed-in turn

  • Session (AgentSession / AgentDraftSession): constructor copies fields from the raw session; does not write back. Draft update() only reassigns private fields from the new response


same comment for async

AsyncTurn / AsyncAgentSession / AsyncAgentDraftSession mirror the sync constructors and only reassign private fields from new responses.


def _adopt_turn_from_created_event(self, event: TurnCreatedEvent) -> None:
"""Build the inner Turn directly from the turn.created event."""
Expand Down Expand Up @@ -733,19 +721,7 @@ def _must_get_turn(self) -> AsyncTurn:
return self._turn

def _adopt_turn_from_api(self, turn: RawTurn) -> None:
self._turn = AsyncTurn(
RawTurn(
id=turn.id,
session_id=turn.session_id,
previous_turn_id=turn.previous_turn_id,
input=turn.input if turn.input is not None else self._input, # type: ignore[arg-type]
state=turn.state,
created_by_subject=turn.created_by_subject,
created_at=turn.created_at,
),
self._session,
self._client,
)
self._turn = AsyncTurn(turn, self._session, self._client)

def _adopt_turn_from_created_event(self, event: TurnCreatedEvent) -> None:
self._turn = AsyncTurn(
Expand Down
Loading