Generate starter code for an AI agent -- system prompt, tool schema and the tool-calling loop -- for Anthropic or OpenAI, in Python or TypeScript. No sign-up required.
"""My Agent -- generated by Aizvi's Agent Harness Boilerplate Generator."""
import anthropic
client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY from the environment
SYSTEM_PROMPT = "You are a helpful, precise assistant. Use the available tools when they help answer the user's question, and give a clear final answer once you have what you need."
# TODO: set MODEL to whichever Claude model you want to use
MODEL = "claude-3-5-sonnet-latest"
TOOLS = [
{
"name": "get_weather",
"description": "Get the current weather for a given location.",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": [
"location"
]
}
}
]
def execute_tool(name: str, tool_input: dict) -> str:
if name == "get_weather":
# TODO: implement get_weather
raise NotImplementedError(f"Tool '{name}' is not implemented yet")
raise ValueError(f"Unknown tool: {name}")
def run_agent(user_message: str, max_iterations: int = 6) -> str:
messages = [{"role": "user", "content": user_message}]
for _ in range(max_iterations):
response = client.messages.create(
model=MODEL,
max_tokens=1024,
system=SYSTEM_PROMPT,
tools=TOOLS,
messages=messages,
)
messages.append({"role": "assistant", "content": response.content})
if response.stop_reason != "tool_use":
return "".join(block.text for block in response.content if block.type == "text")
tool_results = []
for block in response.content:
if block.type == "tool_use":
result = execute_tool(block.name, block.input)
tool_results.append({
"type": "tool_result",
"tool_use_id": block.id,
"content": result,
})
messages.append({"role": "user", "content": tool_results})
return "Max iterations reached without a final answer."
if __name__ == "__main__":
print(run_agent("Hello! What can you help me with?"))
An agent harness is the scaffolding code around a raw LLM call that turns it into a working agent -- the loop that sends messages, checks the response for tool calls, executes them, and feeds the results back until the model produces a final answer. This generator builds that loop for you, along with the system prompt and tool schema, so you can focus on implementing your actual tools instead of the plumbing around them.
An agent harness is the scaffolding code around a raw LLM call that turns it into a working agent -- the loop that sends messages, checks for tool calls, executes them, and feeds the results back until the model produces a final answer.
Yes, completely free with no sign-up required. Everything runs in your browser.
No. Nothing you type here is sent to or stored on our servers -- the code is generated entirely in your browser.
It will run once you install the relevant SDK, set your API key as an environment variable, and implement the TODO stubs for each tool -- it's a working starting point, not a finished agent.
Yes. Add as many tools as you need, each with its own parameters, and they will all be included in the generated tool schema.
Python and TypeScript, for both Anthropic (Claude) and OpenAI -- four combinations in total, each using that provider's official tool-calling format.
This code is generated entirely in your browser -- nothing you type here is sent to or stored on our servers. It's a starting point, not a finished agent: install the relevant SDK, set your API key as an environment variable, and implement the TODO stubs for each tool.
Powered By Aizvi