MCPcopy
hub / github.com/openai/openai-agents-python / test_simple_first_run

Function test_simple_first_run

tests/test_agent_runner.py:533–559  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

531
532@pytest.mark.asyncio
533async def test_simple_first_run():
534 model = FakeModel()
535 agent = Agent(
536 name="test",
537 model=model,
538 )
539 model.set_next_output([get_text_message("first")])
540
541 result = await Runner.run(agent, input="test")
542 assert result.input == "test"
543 assert len(result.new_items) == 1, "exactly one item should be generated"
544 assert result.final_output == "first"
545 assert len(result.raw_responses) == 1, "exactly one model response should be generated"
546 assert result.raw_responses[0].output == [get_text_message("first")]
547 assert result.last_agent == agent
548
549 assert len(result.to_input_list()) == 2, "should have original input and generated item"
550
551 model.set_next_output([get_text_message("second")])
552
553 result = await Runner.run(
554 agent, input=[get_text_input_item("message"), get_text_input_item("another_message")]
555 )
556 assert len(result.new_items) == 1, "exactly one item should be generated"
557 assert result.final_output == "second"
558 assert len(result.raw_responses) == 1, "exactly one model response should be generated"
559 assert len(result.to_input_list()) == 3, "should have original input and generated item"
560
561
562@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 7

set_next_outputMethod · 0.95
AgentClass · 0.90
FakeModelClass · 0.85
get_text_messageFunction · 0.85
get_text_input_itemFunction · 0.85
runMethod · 0.45
to_input_listMethod · 0.45

Tested by

no test coverage detected