Skip to content

Python: Wrapper + Samples#5177

Open
TaoChenOSU wants to merge 10 commits intofeature/python-foundry-hosted-agent-vnextfrom
feature/python-foundry-hosted-agent-vnext-dev
Open

Python: Wrapper + Samples#5177
TaoChenOSU wants to merge 10 commits intofeature/python-foundry-hosted-agent-vnextfrom
feature/python-foundry-hosted-agent-vnext-dev

Conversation

@TaoChenOSU
Copy link
Copy Markdown
Contributor

Motivation and Context

Initial PR to add Python Foundry hosted agent wrapper and samples.

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@TaoChenOSU TaoChenOSU self-assigned this Apr 8, 2026
@moonbox3 moonbox3 added documentation Improvements or additions to documentation python labels Apr 8, 2026
@github-actions github-actions bot changed the title Wrapper + Samples Python: Wrapper + Samples Apr 8, 2026
Copy link
Copy Markdown
Member

@eavanvalkenburg eavanvalkenburg left a comment

Choose a reason for hiding this comment

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

left a bunch of comments, and also really wondering if there is way to make the samples not need 6 files?

prefix: The prefix to prepend (e.g. "foundry-hosting-responses").
"""
if prefix and prefix not in _user_agent_prefixes:
_user_agent_prefixes.append(prefix)
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.

does this mean we are now keeping basically a global list of prefixes added? I don't really like that idea, can't we solve this within the foundry hosting package?

yield update.text

return StreamingResponse(
stream_response(),
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.

I think we should be able to add a transform_hook on the stream object that is returned from run(stream=True) because a ResponseStream should behave like a AsyncGenerator

if self._stream:

async def stream_response() -> AsyncGenerator[str]:
async for update in self._agent.run(user_message, session=session, stream=True):
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 thing here as with the responses, we need ways to pass options along

history = await context.get_history()
messages = [*_to_messages(history), input_items]

chat_options = _to_chat_options(request)
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.

this is a good start, I still think we need more configurability here, but that might also be something we need from the hosted team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants