Skip to content

Conversation

@chakrris
Copy link
Contributor

Summary

Add support for previous_response_id parameter to all OpenAI module run methods, following the same implementation pattern as the existing max_turns parameter from commit 564bedd.

Changes

  • OpenAI Module: Added previous_response_id: str | None = None parameter to all 4 run methods (run_agent, run_agent_auto_send, run_agent_streamed, run_agent_streamed_auto_send)
  • Parameter Classes: Added parameter to RunAgentParams base class, automatically inheriting to all derived classes
  • Service Layer: Implemented conditional logic to handle all combinations of max_turns and previous_response_id parameters
  • Activity Methods: Updated all activity methods to pass the parameter through to service calls
  • Unit Tests: Added comprehensive parametrized test test_run_agent_previous_response_id to verify parameter behavior

Implementation Details

The parameter flows through the following architectural layers:

OpenAI Module → Temporal Activity → OpenAI Service → Runner.run

The service layer uses smart conditional logic to handle all parameter combinations:

  • Both parameters provided: Pass both to Runner.run
  • Only max_turns: Pass only max_turns
  • Only previous_response_id: Pass only previous_response_id
  • Neither provided: Call Runner.run with no optional parameters

Test Coverage

  • ✅ All existing tests continue to pass (15/15)
  • ✅ New unit test verifies parameter is passed when provided and omitted when None
  • ✅ Parametrized test covers both scenarios with mock verification

Backward Compatibility

This change is fully backward compatible - the parameter defaults to None and existing code will continue to work unchanged.

Add support for previous_response_id parameter to all OpenAI module run methods,
following the same implementation pattern as the existing max_turns parameter.

Changes:
- Add previous_response_id parameter to all 4 OpenAI module run methods
- Update parameter classes in openai_activities.py to inherit the parameter
- Implement conditional logic in service layer to handle parameter combinations
- Add comprehensive unit test to verify parameter passing behavior

The parameter flows through the following layers:
Module → Activity → Service → Runner.run

This enables conversation continuity by allowing users to specify a previous
response ID when running OpenAI agents.
@chakrris chakrris merged commit 7a78844 into main Sep 12, 2025
7 of 8 checks passed
@chakrris chakrris deleted the chakrris/previous-response-id branch September 12, 2025 13:36
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