The extension was experiencing a "Self-Reading" loop where raw HTML from the extension's own index.html file was being displayed in the chat window instead of AI responses from OpenRouter.
A trailing space in the Authorization header (Bearer ${apiKey} instead of Bearer ${apiKey}) was causing API authentication to fail silently, potentially leading to fallback behavior that loaded local files.
File: src/extension.ts (Line 366)
Before:
"Authorization": `Bearer ${apiKey} `,After:
"Authorization": `Bearer ${apiKey}`,Impact: Ensures proper API authentication with OpenRouter without trailing whitespace.
File: src/extension.ts (Lines 425-427)
Added clear documentation to the callModelAPI function:
// CRITICAL FIX v5.2.3: FORCE NETWORK CALL - DO NOT LOAD LOCAL FILES
// This prevents the "Self-Reading" loop where the extension would fetch its own index.html
private async callModelAPI(apiKey: string, model: string, prompt: string, roleInfo: string): Promise<any> {Impact: Makes the intent explicit for future maintainers.
✅ API Endpoint Verification
- The
callModelAPIfunction uses hardcoded URL:https://openrouter.ai/api/v1/chat/completions - No file path resolution or local resource loading
- Returns structured object:
{ text: data.choices[0].message.content }
✅ Safe Text Rendering
- Webview uses
textContentinstead ofinnerHTML(Line 107 insrc/webview/script.js) - HTML tags are stripped as fallback in orchestration logic (Line 285 in
src/extension.ts)
✅ Error Transparency
- Clear error messages for API failures:
OpenRouter Error (${response.status}): ${errorBody} - Network errors are caught and reported to the user
-
Test API Connectivity
- Open the DepthOS Bridge panel
- Navigate to SETTINGS tab
- Click "🔍 Test Connectivity" button
- Verify you see: "✅ DepthOS: OpenRouter connection successful!"
-
Test Chat Functionality
- Switch to CHAT tab
- Click "Initialize Orchestration"
- Send a test query (e.g., "Hello, can you hear me?")
- Verify you receive a proper AI response, not HTML code
-
Verify Logs
- Open Output panel (View → Output)
- Select "DepthOS Bridge" from dropdown
- Look for successful API calls and responses
- Extension rebuilt:
dist/extension.js(784.4kb) - Server rebuilt:
dist/server.js(969.1kb) - Package created:
depthos-bridge-5.0.0.vsix - Installation: Successfully installed in Antigravity
If you still see HTML in the chat after these fixes:
- Reload the VS Code window:
Cmd+Shift+P→ "Developer: Reload Window" - Check API Key: Ensure your OpenRouter API key is valid and has credits
- Review Output Logs: Check for specific error messages in the DepthOS Bridge output channel
- Test with Simple Query: Try a basic prompt like "What is 2+2?" to isolate the issue
HTTP Authorization headers are sensitive to exact formatting. The trailing space could cause:
- API key validation failures
- Silent fallbacks to error handling paths
- Potential confusion in request routing
By hardcoding the OpenRouter URL and explicitly structuring the response, we ensure:
- No ambiguity in endpoint resolution
- No chance of local file path confusion
- Consistent error handling and reporting