(model: str)
| 51 | |
| 52 | |
| 53 | async def main(model: str) -> None: |
| 54 | inline_skill = build_inline_skill() |
| 55 | |
| 56 | with trace("container_shell_inline_skill_example"): |
| 57 | agent1 = Agent( |
| 58 | name="Container Shell Agent (Inline Skill)", |
| 59 | model=model, |
| 60 | instructions="Use the available container skill to answer user requests.", |
| 61 | tools=[ |
| 62 | ShellTool( |
| 63 | environment={ |
| 64 | "type": "container_auto", |
| 65 | "network_policy": {"type": "disabled"}, |
| 66 | "skills": [inline_skill], |
| 67 | } |
| 68 | ) |
| 69 | ], |
| 70 | ) |
| 71 | |
| 72 | result1 = await Runner.run( |
| 73 | agent1, |
| 74 | ( |
| 75 | "Use the csv-workbench skill. Create /mnt/data/orders.csv with columns " |
| 76 | "id,region,amount,status and at least 6 rows. Then report total amount by " |
| 77 | "region and count failed orders." |
| 78 | ), |
| 79 | ) |
| 80 | print(f"Agent: {result1.final_output}") |
| 81 | |
| 82 | container_id = extract_container_id(result1.raw_responses) |
| 83 | if not container_id: |
| 84 | raise RuntimeError("Container ID was not returned in shell call output.") |
| 85 | |
| 86 | print(f"[info] Reusing container_id={container_id}") |
| 87 | |
| 88 | agent2 = Agent( |
| 89 | name="Container Reference Shell Agent", |
| 90 | model=model, |
| 91 | instructions="Reuse the existing shell container and answer concisely.", |
| 92 | tools=[ |
| 93 | ShellTool( |
| 94 | environment={ |
| 95 | "type": "container_reference", |
| 96 | "container_id": container_id, |
| 97 | } |
| 98 | ) |
| 99 | ], |
| 100 | ) |
| 101 | |
| 102 | result2 = await Runner.run( |
| 103 | agent2, |
| 104 | "Run `ls -la /mnt/data`, then summarize in one sentence.", |
| 105 | ) |
| 106 | print(f"Agent (container reuse): {result2.final_output}") |
| 107 | |
| 108 | |
| 109 | if __name__ == "__main__": |
no test coverage detected