Skip to content

AGE-1957: Pass create_turn turn through without any fallback. - #17

Merged
bhaveshpatel640 merged 1 commit into
mainfrom
AGE-1957-fixes
Aug 25, 2026
Merged

AGE-1957: Pass create_turn turn through without any fallback.#17
bhaveshpatel640 merged 1 commit into
mainfrom
AGE-1957-fixes

Conversation

@bhaveshpatel640

@bhaveshpatel640 bhaveshpatel640 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

AGE-1957: Pass create_turn turn through without any fallback.


Note

Low Risk
Small SDK behavior change: turn input after JSON create_turn now reflects the API response only, which may differ from prior local fallback when the server leaves input empty.

Overview
PreparedTurn and AsyncPreparedTurn now adopt the create_turn / get_turn payload as-is when using the non-streaming path (execute(stream=False)).

_adopt_turn_from_api no longer rebuilds a RawTurn or substitutes staged self._input when the API omits input; it wraps the returned RawTurn directly in Turn / AsyncTurn. The streaming turn.created adoption path is unchanged and still builds a turn from the event plus local input.

Reviewed by Cursor Bugbot for commit 7c48fff. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Improved turn adoption from API responses by preserving the returned turn data.
    • Prevented staged input from incorrectly replacing response input when no response input is provided.

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ab34f5a4-5302-4f88-a870-cb7527942ef9

📥 Commits

Reviewing files that changed from the base of the PR and between 5c8dfc0 and 7c48fff.

📒 Files selected for processing (1)
  • src/truefoundry_gateway_sdk/agents/prepared_turn.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The synchronous and asynchronous API adoption paths now pass the returned RawTurn directly to Turn and AsyncTurn. Manual field reconstruction and staged-input fallback were removed.

Changes

Turn adoption

Layer / File(s) Summary
Direct RawTurn wrapper construction
src/truefoundry_gateway_sdk/agents/prepared_turn.py
Synchronous and asynchronous adoption now constructs Turn and AsyncTurn directly from the API-provided RawTurn. Manual field copying and staged-input fallback were removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 7c48f

This is a localized SDK behavior change, and no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: chiragjn

Poem

A rabbit checks the turn with care
The raw API shape is carried there
No staged crumbs replace the truth
Sync and async both hop in tune
Clean wrappers spring from fields anew

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: passing the create_turn turn through without fallback behavior. It is concise and specific.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch AGE-1957-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

@bhaveshpatel640
bhaveshpatel640 merged commit c0e01cf into main Aug 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants