Coding Agent: GPT-4.1 + Agents SDK
Building a coding agent with GPT-4.1 via the OpenAI Agents SDK: web_search + shell tools, ShellExecutor with an isolated workspace, scaffold → feedback → iteration loop.
Run the coding agent with an instruction to create a simple Flask app with a single /health endpoint. Make sure the agent uses ShellExecutor in an isolated directory and you can approve/reject each command.
Task grader
Copy and adapt to your context. Text in angle brackets should be replaced.
import asyncio
from pathlib import Path
from agents import Agent, Runner, WebSearchTool
workspace_dir = Path("agent-workspace").resolve()
workspace_dir.mkdir(exist_ok=True)
agent = Agent(
name="DevAgent",
model="gpt-4.1",
instructions="Scaffold a minimal Flask app with /health endpoint in the workspace.",
tools=[WebSearchTool()],
)
async def main():
runner = Runner(agent=agent)
result = await runner.run(
"Create a Flask app with a /health endpoint returning JSON {status: ok}"
)
print(result.final_output)
asyncio.run(main())