Basic Usage
Any parameter incallModel can be a function that computes its value based on conversation context. This enables adaptive behavior - changing models, adjusting temperature, or modifying instructions as the conversation evolves.
Pass a function instead of a static value:
Function Signature
Parameter functions receive aTurnContext and return the parameter value:
TurnContext
| Property | Type | Description |
|---|---|---|
numberOfTurns | number | Current turn number (1-indexed) |
turnRequest | OpenResponsesRequest | undefined | Current request object containing messages and model settings |
toolCall | OpenResponsesFunctionToolCall | undefined | The specific tool call being executed |
Async Functions
Functions can be async for fetching external data:Common Patterns
Progressive Model Upgrade
Start with a fast model, upgrade for complex tasks:Adaptive Temperature
Adjust creativity based on context:Context-Aware Instructions
Build instructions based on conversation state:Dynamic Max Tokens
Adjust output length based on task:Feature Flags
Enable features dynamically:Combining with Tools
Dynamic parameters work alongside tool execution:Execution Order
Dynamic parameters are resolved at the start of each turn:Error Handling
Handle errors in async parameter functions:Best Practices
Keep Functions Pure
Avoid side effects in parameter functions:Cache Expensive Operations
Cache results for repeated calls:Use Sensible Defaults
Always have fallback values:See Also
- nextTurnParams - Tool-driven parameter modification
- Stop Conditions - Dynamic execution control
- Tools - Multi-turn orchestration