Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion responses_api_agents/simple_agent/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def _create_episode(
model_calls: list[ModelCallRef] = []
turns: list[TrajectoryTurn] = []
trajectory_gaps: list[ObservationGap] = []
body = body.model_copy(deep=True)
body = body.model_copy()

if isinstance(body.input, str):
body.input = [NeMoGymEasyInputMessage(role="user", content=body.input)]
Expand Down
40 changes: 40 additions & 0 deletions responses_api_agents/simple_agent/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,46 @@ async def test_responses(self, monkeypatch: MonkeyPatch) -> None:
assert prefixed_response.status_code == 200
assert prefixed_response.json()["_ng_trajectory"]["rollout_id"] == "0-0"

@pytest.mark.parametrize(
"input_value",
(
"question",
[{"role": "user", "content": [{"type": "input_text", "text": "question"}]}],
),
)
async def test_create_episode_does_not_mutate_request(self, input_value) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this also test tool call, incomplete response, nested tool schema, failure paths?

server, server_client = _make_agent(False)
server_client.post = AsyncMock(
return_value=_mock_response(
{
"id": "response-1",
"created_at": 1.0,
"model": "model",
"object": "response",
"output": [
{
"id": "message-1",
"content": [{"annotations": [], "text": "answer", "type": "output_text"}],
"role": "assistant",
"status": "completed",
"type": "message",
}
],
"parallel_tool_calls": True,
"tool_choice": "auto",
"tools": [],
}
)
)
body = NeMoGymResponseCreateParamsNonStreaming.model_validate(
{"input": input_value, "metadata": {"nested": '{"value":[1,2,3]}'}}
)
body_before = body.model_dump()

await server._create_episode(body, model_url_path="/v1/responses")

assert body.model_dump() == body_before

@pytest.mark.parametrize("resolved", [False, None])
async def test_run_emits_standard_turns_and_tool_observation(self, resolved: bool | None) -> None:
server, server_client = _make_agent(True)
Expand Down
Loading