Skip to content

Conversation

@gvdongen
Copy link
Contributor

This pull request makes significant improvements to the Restate OpenAI integration, focusing on enhanced LLM call retry configuration, session management, and simplifying the agent runner interface. The most important changes are grouped below.

LLM Retry and Durable Model Calls:

  • Introduced the LlmRetryOpts dataclass to allow fine-grained configuration of retry behavior for LLM calls, including maximum attempts, duration, intervals, and backoff factor. The DurableModelCalls and RestateModelWrapper classes were updated to use this new configuration, replacing the previous simple retry count. ([[1]](https://github.com/restatedev/sdk-python/pull/164/files#diff-bcfe297c913d38628b0f9bee4137165993514de2182421c3fb86f6f4df0e2f86L15-R69), [[2]](https://github.com/restatedev/sdk-python/pull/164/files#diff-bcfe297c913d38628b0f9bee4137165993514de2182421c3fb86f6f4df0e2f86L74-R112), [[3]](https://github.com/restatedev/sdk-python/pull/164/files#diff-bcfe297c913d38628b0f9bee4137165993514de2182421c3fb86f6f4df0e2f86L105-R137))

Session Management Improvements:

  • Enhanced the RestateSession class to cache session items in memory, reducing redundant context fetches. Added a flush method to persist changes and updated add_items, get_items, and pop_item to use the cache. Now, session state is explicitly flushed after agent runs. ([[1]](https://github.com/restatedev/sdk-python/pull/164/files#diff-bcfe297c913d38628b0f9bee4137165993514de2182421c3fb86f6f4df0e2f86R152-R188), [[2]](https://github.com/restatedev/sdk-python/pull/164/files#diff-bcfe297c913d38628b0f9bee4137165993514de2182421c3fb86f6f4df0e2f86L216-R284))

Runner and Agent Execution Simplification:

  • Replaced the Runner class with DurableRunner, simplifying the agent run interface. The run method now takes input and llm_retry_opts directly, configures the model provider and disables parallel tool calls via ModelSettings, and automatically flushes session state. The previous tool wrapping logic was removed in favor of built-in sequentialization. ([[1]](https://github.com/restatedev/sdk-python/pull/164/files#diff-bcfe297c913d38628b0f9bee4137165993514de2182421c3fb86f6f4df0e2f86L192-R234), [[2]](https://github.com/restatedev/sdk-python/pull/164/files#diff-bcfe297c913d38628b0f9bee4137165993514de2182421c3fb86f6f4df0e2f86L204-R246), [[3]](https://github.com/restatedev/sdk-python/pull/164/files#diff-bcfe297c913d38628b0f9bee4137165993514de2182421c3fb86f6f4df0e2f86L216-R284))

Public API and Utility Functions:

  • Updated the public API in __init__.py to export DurableRunner, RestateSession, LlmRetryOpts, and new utility functions restate_object_context and restate_context for easier context access. ([python/restate/ext/openai/__init__.pyL15-L21](https://github.com/restatedev/sdk-python/pull/164/files#diff-484be77d523f4d783c48e3a57394969cb6ae3a6c383b69c5a11fd25162c806a9L15-L21))

These changes collectively make the OpenAI integration for Restate more robust, configurable, and easier to use.

…ing model retry opts, set parallel_tool_calls to false
…ing model retry opts, set parallel_tool_calls to false
@gvdongen gvdongen requested a review from igalshilman December 15, 2025 13:27
@github-actions
Copy link

github-actions bot commented Dec 15, 2025

Test Results

  7 files  ±0    7 suites  ±0   4m 18s ⏱️ -6s
 49 tests ±0   49 ✅ ±0  0 💤 ±0  0 ❌ ±0 
210 runs  ±0  210 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 73bfa10. ± Comparison against base commit a4765b0.

♻️ This comment has been updated with latest results.

if limit is not None:
return current_items[-limit:]
return current_items
return self._items[-limit:]
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure about this?
this seems to take the last limit items (the negative sign) ?

for handoff in agent.handoffs:
# recursively wrap tools in handoff agents
handoffs_with_wrapped_tools.append(sequentialize_and_wrap_tools(handoff, disable_tool_autowrapping)) # type: ignore
runner = DEFAULT_AGENT_RUNNER or AgentRunner()
Copy link
Contributor

Choose a reason for hiding this comment

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

what is happening here? should we just delegate to the OpenAI runner?

@gvdongen gvdongen merged commit a32145b into main Dec 16, 2025
7 checks passed
@gvdongen gvdongen deleted the openai_integration branch December 16, 2025 13:46
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants