1.8 KiB
1.8 KiB
Walkthrough: Enhanced Agent Communication
I have successfully integrated the enhanced system prompt, retry mechanism, and TUI formatters.
Changes Applied
1. Robust API Calls (qwen-oauth.mjs)
- Retry Logic: Integrated
fetchWithRetryfor Vision API calls. - Dynamic System Prompt:
sendMessagenow accepts asystemPromptargument, allowing the TUI to inject context-aware instructions instead of relying on hardcoded overrides.
2. TUI Logic (bin/opencode-ink.mjs)
- System Prompt Injection:
handleSubmitnow generates a clean, role-specific system prompt usinglib/agent-prompt.mjs. - Stream Refactoring: Unified the streaming callback logic for cleaner code.
- Retry Integration:
callOpenCodeFreenow usesfetchWithRetryfor better resilience. - Visual Feedback: File save operations now use
formatSuccessandformatFileOperationfor consistent, bordered output.
Verification Steps
Important
You MUST restart your TUI process (
node bin/opencode-ink.mjs) for these changes to take effect.
- Restart the TUI.
- Test System Prompt:
- Send a simple greeting: "Hello".
- Expected: A concise, direct response (no "As an AI..." preamble).
- ask "Create a file named
demo.txtwith text 'Hello World'". - Expected: The agent should generate the file using the correct code block format.
- Test Visual Feedback:
- Observe the success message after file creation.
- Expected: A green bordered box saying "✅ Success" with the file details.
- Test Retry (Optional):
- If you can simulate a network glitch, the system should now log "Retrying...".
Rollback
Backups were created before applying changes:
qwen-oauth.mjs.bakbin/opencode-ink.mjs.bak