learn-claude-code icon indicating copy to clipboard operation
learn-claude-code copied to clipboard

feat: migrate s01-s12 agent loop from Anthropic to OpenAI

Open qingzheng-web opened this issue 6 months ago • 2 comments

Description

Replace Claude API with OpenAI API.

Changes

  • Replace anthropic library with openai library
  • Adjust tool definition format to match OpenAI function calling spec
  • Modify API call method (messages.create → chat.completions.create)
  • Adapt tool_calls response format and tool result return format
  • Add cross-platform support (Windows/Linux encoding handling)
  • Adjust message structure and stop condition logic
  • Preserve original agent loop core logic

Affected files

  • agents/openai_code/

Testing

✅ Local tests pass, OpenAI API responds correctly

Note

Requires OPENAI_API_KEY OPENAI_BASE_URL``OPENAI_MODEL_ID environment variable after merge.

qingzheng-web avatar May 03 '26 03:05 qingzheng-web

@qingzheng-web is attempting to deploy a commit to the crazyboym's projects Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar May 03 '26 03:05 vercel[bot]

Hi maintainers, I see the deployment is pending authorization. If needed, please approve when you have time. Thanks!

qingzheng-web avatar May 03 '26 06:05 qingzheng-web

Thanks for taking the time to port this, it is clearly real work and I appreciate it, but I am going to close it and would rather be honest about why: this course is specifically about how Claude Code works and is built on the Anthropic API throughout, and I do not plan to maintain a second backend on OpenAI, since every teaching change afterward would need an OpenAI mirror kept in sync and that ongoing cost lands on me. On top of that the course has moved on, it now runs through s20 while this port covers only s01 through s12 of the older layout, so it is already behind the current material. None of this is a knock on the effort, and you are welcome to keep your OpenAI version in your own fork for anyone who finds it useful. Thanks again for giving the material a serious read.

Bill-Billion avatar Jun 26 '26 18:06 Bill-Billion