AxiosError: Error Encountered During Code Structuring with Claude-Agent-SDK
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
While using the claude-agent-sdk to perform code structuring, an error was encountered. The error logs indicate an AxiosError, but the root cause is unclear. Assistance is needed to diagnose and resolve this issue.
code:return ClaudeAgentOptions(
system_prompt={
"type": "preset",
"preset": "claude_code",
"append": """# 目标:根据用户要求生成代码\n## 输入:\n\t- 用户要求\n\t- 规则信息"""
},
permission_mode="bypassPermissions",
setting_sources=["project"],
cwd=working_dir,
max_turns=2000,
hooks={
"PreToolUse": [
HookMatcher(matcher="Bash", hooks=[block_mvn_and_git_hook]),
],
"PostToolUse": [
HookMatcher(matcher="*", hooks=[continue_on_error_hook]),
]
},
env=dict(os.environ)
)
What Should Happen?
The code structuring process should complete without errors.
Error Messages/Logs
5-12-08T07:58:55.428Z [DEBUG] Getting matching hook commands for PostToolUse with query: Glob
2025-12-08T07:58:55.428Z [DEBUG] Found 1 hook matchers in settings
2025-12-08T07:58:55.428Z [DEBUG] Matched 1 unique hooks for query "Glob" (1 before deduplication)
2025-12-08T07:58:55.437Z [DEBUG] LSP Diagnostics: getLSPDiagnosticAttachments called
2025-12-08T07:58:55.437Z [DEBUG] LSP Diagnostics: Checking registry - 0 pending
2025-12-08T07:58:55.437Z [DEBUG] Hooks: Found 0 total hooks in registry
2025-12-08T07:58:55.437Z [DEBUG] Hooks: checkForNewResponses returning 0 responses
2025-12-08T07:58:57.685Z [ERROR] "AxiosError: Error\n at <anonymous> (/$bunfs/root/claude:32:10674)\n at emit (node:events:92:22)\n at <anonymous> (/$bunfs/root/claude:31:3314)\n at request (/$bunfs/root/claude:34:2147)\n at processTicksAndRejections (native:7:39)"
2025-12-08T07:58:58.595Z [DEBUG] Stream started - received first chunk
2025-12-08T07:58:59.564Z [DEBUG] executePreToolHooks called for tool: Bash
2025-12-08T07:58:59.564Z [DEBUG] Getting matching hook commands for PreToolUse with query: Bash
2025-12-08T07:58:59.564Z [DEBUG] Found 1 hook matchers in settings
2025-12-08T07:58:59.564Z [DEBUG] Matched 1 unique hooks for query "Bash" (1 before deduplication)
2025-12-08T07:58:59.633Z [DEBUG] Getting matching hook commands for PostToolUse with query: Bash
2025-12-08T07:58:59.633Z [DEBUG] Found 1 hook matchers in settings
2025-12-08T07:58:59.633Z [DEBUG] Matched 1 unique hooks for query "Bash" (1 before deduplication)
2025-12-08T07:58:59.642Z [DEBUG] LSP Diagnostics: getLSPDiagnosticAttachments called
2025-12-08T07:58:59.642Z [DEBUG] LSP Diagnostics: Checking registry - 0 pending
2025-12-08T07:58:59.642Z [DEBUG] Hooks: Found 0 total hooks in registry
2025-12-08T07:58:59.642Z [DEBUG] Hooks: checkForNewResponses returning 0 responses
2025-12-08T07:59:00.498Z [DEBUG] Stream started - received first chunk
2025-12-08T07:59:14.767Z [ERROR] "AxiosError: Error\n at <anonymous> (/$bunfs/root/claude:32:10674)\n at emit (node:events:92:22)\n at <anonymous> (/$bunfs/root/claude:31:3314)\n at request (/$bunfs/root/claude:34:2147)\n at processTicksAndRejections (native:7:39)"
2025-12-08T07:59:20.947Z [DEBUG] Metrics opt-out check failed: No API key available
2025-12-08T07:59:20.948Z [DEBUG] Metrics check failed, defaulting to disabled
2025-12-08T07:59:20.948Z [DEBUG] Metrics export disabled by organization setting
2025-12-08T07:59:51.627Z [DEBUG] Stream started - received first chunk
2025-12-08T07:59:52.090Z [DEBUG] executePreToolHooks called for tool: Bash
2025-12-08T07:59:52.091Z [DEBUG] Getting matching hook commands for PreToolUse with query: Bash
2025-12-08T07:59:52.091Z [DEBUG] Found 1 hook matchers in settings
2025-12-08T07:59:52.091Z [DEBUG] Matched 1 unique hooks for query "Bash" (1 before deduplication)
2025-12-08T07:59:52.170Z [DEBUG] Getting matching hook commands for PostToolUse with query: Bash
2025-12-08T07:59:52.170Z [DEBUG] Found 1 hook matchers in settings
2025-12-08T07:59:52.170Z [DEBUG] Matched 1 unique hooks for query "Bash" (1 before deduplication)
2025-12-08T07:59:52.187Z [DEBUG] LSP Diagnostics: getLSPDiagnosticAttachments called
2025-12-08T07:59:52.187Z [DEBUG] LSP Diagnostics: Checking registry - 0 pending
2025-12-08T07:59:52.188Z [DEBUG] Hooks: Found 0 total hooks in registry
2025-12-08T07:59:52.188Z [DEBUG] Hooks: checkForNewResponses returning 0 responses
2025-12-08T08:00:03.960Z [DEBUG] Stream started - received first chunk
2025-12-08T08:00:07.263Z [DEBUG] Stream started - received first chunk
2025-12-08T08:00:08.670Z [DEBUG] executePreToolHooks called for tool: Bash
2025-12-08T08:00:08.671Z [DEBUG] Getting matching hook commands for PreToolUse with query: Bash
2025-12-08T08:00:08.671Z [DEBUG] Found 1 hook matchers in settings
2025-12-08T08:00:08.671Z [DEBUG] Matched 1 unique hooks for query "Bash" (1 before deduplication)
2025-12-08T08:00:12.096Z [ERROR] "AxiosError: Error\n at <anonymous> (/$bunfs/root/claude:32:10674)\n at emit (node:events:92:22)\n at <anonymous> (/$bunfs/root/claude:31:3314)\n at request (/$bunfs/root/claude:34:2147)\n at processTicksAndRejections (native:7:39)"
2025-12-08T08:00:14.199Z [DEBUG] Stream started - received first chunk
2025-12-08T08:00:14.424Z [DEBUG] Stream started - received first chunk
2025-12-08T08:00:14.580Z [DEBUG] Getting matching hook commands for PostToolUse with query: Bash
2025-12-08T08:00:14.580Z [DEBUG] Found 1 hook matchers in settings
Steps to Reproduce
return ClaudeAgentOptions(
system_prompt={
"type": "preset",
"preset": "claude_code",
"append": """# 目标:根据用户要求生成代码\n## 输入:\n\t- 用户要求\n\t- 规则信息"""
},
permission_mode="bypassPermissions",
setting_sources=["project"],
cwd=working_dir,
max_turns=2000,
hooks={
"PreToolUse": [
HookMatcher(matcher="Bash", hooks=[block_mvn_and_git_hook]),
],
"PostToolUse": [
HookMatcher(matcher="*", hooks=[continue_on_error_hook]),
]
},
env=dict(os.environ)
)
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.58 (Claude Code)
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
PyCharm terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗