一键导入
debugging
Debug issues in Copex, especially streaming, content display, and event handling bugs. Use this when investigating bugs, unexpected behavior, or errors.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Debug issues in Copex, especially streaming, content display, and event handling bugs. Use this when investigating bugs, unexpected behavior, or errors.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | debugging |
| description | Debug issues in Copex, especially streaming, content display, and event handling bugs. Use this when investigating bugs, unexpected behavior, or errors. |
Symptoms: Response shows previous turn's content, or old message appears instead of new one.
Root Cause: History fallback triggered during streaming mode.
Investigation:
on_chunk provided)received_content flag is set when content arrivesFix Pattern:
# In client.py - only use history when NOT streaming
if not received_content and on_chunk is None:
# History fallback OK here
messages = await session.get_messages()
In CLI - prefer streamed content:
final_message = ui.state.message if ui.state.message else response.content
Symptoms: Response is empty, reasoning missing, or incomplete.
Debug Steps:
on_event():
print(f"Event: {event_type}, data: {event.data}")
content_parts and reasoning_parts listsEvent Flow:
ASSISTANT_REASONING_DELTA → reasoning_parts.append()
ASSISTANT_REASONING → final_reasoning = content
ASSISTANT_MESSAGE_DELTA → content_parts.append()
ASSISTANT_MESSAGE → final_content = content
SESSION_IDLE → done.set()
Check:
_should_retry() logic in client.pyretry_on_errors patternsretry_on_any_error config settingDebug:
print(f"Error: {error_str}")
print(f"Should retry: {self._should_retry(e)}")
Check: last_activity timestamp updates in on_event():
def on_event(event):
nonlocal last_activity
last_activity = asyncio.get_event_loop().time() # Must update!
| Issue | File | Function |
|---|---|---|
| Content/streaming | client.py | _send_once(), on_event() |
| UI display | cli.py | _stream_response*() |
| UI components | ui.py | CopexUI, build_*() |
| Retry logic | client.py | send(), _should_retry() |
| Config | config.py | CopexConfig |
response = await client.send(prompt)
for event in response.raw_events:
print(f"{event['type']}: {event['data']}")
def test_reproduces_bug():
events = [
# Exact sequence that causes the bug
]
session = FakeSession(events)
# Verify bug exists, then fix
Review code changes in Copex for bugs, style issues, and best practices. Use this when reviewing PRs or code changes.
Add new features to Copex. Use this when asked to implement new functionality, add CLI commands, or extend the client.
Release and publish Copex to PyPI. Use this when asked to release, publish, bump version, or create a new version.
Write and run tests for Copex. Use this when asked to write tests, fix tests, improve coverage, or debug test failures.