opencode-pollinations-plugin 5.8.4-beta.3 → 5.8.4-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -153,6 +153,11 @@ export async function handleChatCompletion(req, res, bodyRaw) {
153
153
  const config = loadConfig();
154
154
  // DEBUG: Trace Config State for Hot Reload verification
155
155
  log(`[Proxy Request] Config Loaded. Mode: ${config.mode}, HasKey: ${!!config.apiKey}, KeyLength: ${config.apiKey ? config.apiKey.length : 0}`);
156
+ // SPY LOGGING
157
+ try {
158
+ fs.appendFileSync('/tmp/opencode_spy.log', `\n\n=== REQUEST ${new Date().toISOString()} ===\nMODEL: ${body.model}\nBODY:\n${JSON.stringify(body, null, 2)}\n==========================\n`);
159
+ }
160
+ catch (e) { }
156
161
  // 0. COMMAND HANDLING
157
162
  if (body.messages && body.messages.length > 0) {
158
163
  const lastMsg = body.messages[body.messages.length - 1];
@@ -424,6 +429,22 @@ export async function handleChatCompletion(req, res, bodyRaw) {
424
429
  if (proxyBody.tools && Array.isArray(proxyBody.tools)) {
425
430
  hasFunctions = proxyBody.tools.some((t) => t.type === 'function' || t.function);
426
431
  }
432
+ // BEDROCK FIX: Check if history has tools but current request misses tools definition
433
+ // This happens when OpenCode sends the Tool Result: it optimizes by removing "tools" definition,
434
+ // but Bedrock requires toolConfig to validate the history.
435
+ const hasToolHistory = proxyBody.messages?.some((m) => m.role === 'tool' || m.tool_calls);
436
+ if (hasToolHistory && (!proxyBody.tools || proxyBody.tools.length === 0)) {
437
+ // Inject Shim Tool to satisfy Bedrock
438
+ proxyBody.tools = [{
439
+ type: 'function',
440
+ function: {
441
+ name: '_bedrock_compatibility_shim',
442
+ description: 'Internal system tool to satisfy Bedrock strict toolConfig requirement. Do not use.',
443
+ parameters: { type: 'object', properties: {} }
444
+ }
445
+ }];
446
+ log(`[Proxy] Bedrock Fix: Injected shim tool for ${actualModel} (History has tools, Request missing tools)`);
447
+ }
427
448
  if (hasFunctions) {
428
449
  // 1. Strict cleanup of 'google_search' tool
429
450
  proxyBody.tools = proxyBody.tools.filter((t) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-pollinations-plugin",
3
3
  "displayName": "Pollinations AI (V5.6)",
4
- "version": "5.8.4-beta.3",
4
+ "version": "5.8.4-beta.5",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {