---
type: email
from: RoomWithOutRoof <notifications@github.com>
subject: [openai/openai-agents-python] feat: add rejection_message parameter

 to RunState.reject() (PR #2659)
received: 2026-03-12 18:11:06
date_header: Thu, 12 Mar 2026 05:41:27 -0700
priority: normal
status: awaiting_approval
uid: 45458
---

## Email Content

**From:** RoomWithOutRoof <notifications@github.com>
**Subject:** [openai/openai-agents-python] feat: add rejection_message parameter

 to RunState.reject() (PR #2659)
**Date:** Thu, 12 Mar 2026 05:41:27 -0700

### Body (preview)

## Summary



Add optional `rejection_message` parameter to `RunState.reject()` method to allow passing a specific reason for tool call rejection to the model.



## Problem



When using the Human-in-the-loop (HITL) feature, rejecting a tool call via `RunState.reject()` currently only tells the model that execution was &quot;not approved&quot; — there is no way to communicate WHY the call was rejected.



This makes it difficult for the model to understand context and adjust its response accordingly.



## Solution



Add a new optional `rejection_message` parameter to `RunState.reject()`:



```python

state = result.to_state()

for interruption in result.interruptions:

    reason = ask_user_why_they_rejected(interruption)

    state.reject(

        interruption,

        rejection_message=reason,  # ← new parameter

    )

result = await Runner.run(agent, state)

```



## Changes



1. **run_config.py**: Add `rejection_message` field to `ToolErrorFormatterArgs`

2. **run_state.py**: Add `rejection_message` parameter to `RunState.reject()` method

3. **run_context.py**: Store rejection message in context and pass to formatter

4. **tool_execution.py**: Pass rejection message to tool error formatter



## Testing



- [ ] Test with custom tool error formatter

- [ ] Test without custom formatter (should use rejection_message if provided)

- [ ] Test serialization/deserialization of RunState



## Related



Fixes #2658



---



Good day! I hope this contribution helps. Please let me know if there are any issues or if the implementation needs adjustment. I am happy to make changes.



Warmly,

Jah-yee

You can view, comment on, or merge this pull request online at:



  https://github.com/openai/openai-agents-python/pull/2659



-- Commit Summary --



  * feat: add rejection_message parameter to RunState.reject()



-- File Changes --



    M src/agents/run_config.py (3)

    M src/agents/run_context.py (19)

    M src/agents/run_internal/tool_execution.py (10

---

## Suggested Actions
- [ ] Reply
- [ ] Archive
- [ ] Escalate
