YUNOVA · AI Agents · Module 9: Agents with the OpenAI and Claude SDKs
The agent loop in code
The agent loop in code
Key points
- Agent loop में code बार-बार model को call करता है जब तक model tool call माँगना बंद न कर दे।
- हर बार model का जवाब और tool का result messages की list में जोड़ा जाता है।
- Claude API में stop_reason 'tool_use' बताता है कि model tool चलवाना चाहता है।
- Loop में अधिकतम iterations की सीमा और error handling ज़रूर रखें।