Skip to content

Pr 140 bypass sdk#161

Merged
tickernelz merged 7 commits into
mainfrom
pr-140-bypass-sdk
Jul 9, 2026
Merged

Pr 140 bypass sdk#161
tickernelz merged 7 commits into
mainfrom
pr-140-bypass-sdk

Conversation

@GraDea

@GraDea GraDea commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to merged #140. PR #140 fixed the first layer of issue #110 by bypassing brittle OpenCode v2 SDK session helper methods and calling the raw session HTTP endpoints directly.

This PR fixes the next runtime layer: in the OpenCode plugin host, those raw HTTP calls still should not rely on plain/global fetch assumptions. They need to use OpenCode’s host SDK transport (fetch/baseUrl) when available.

What #140 fixed

#140 replaced calls through generated SDK session helpers such as:

  • client.session.create
  • client.session.prompt
  • client.session.delete

with direct calls to the OpenCode server endpoints:

  • POST /session
  • POST /session/{id}/message
  • DELETE /session/{id}

That addressed SDK method-shape incompatibility across OpenCode/SDK versions.

Why this follow-up is still needed

After #140 was merged, we tested fresh origin/main at 6b564a0 through the real plugin surface:

  • checked out fresh main
  • reset to origin/main
  • confirmed local OpenCode config points to /home/peshkov/src/opencode-mem
  • confirmed auto-capture config:
    • autoCaptureEnabled: true
    • opencodeProvider: openai
    • opencodeModel: gpt-5.5
  • ran bun install
  • ran bun run build
  • restarted OpenCode and triggered manual auto-capture

Main still failed at runtime:

Auto-capture warning (attempt 1/3): Unable to connect. Is the computer able to access the url?
Auto-capture warning (attempt 2/3): Unable to connect. Is the computer able to access the url?
Auto-capture final error after 3 attempts: Unable to connect. Is the computer able to access the url?

So #140 fixed SDK helper incompatibility, but not the plugin-host transport failure.
Changes in this PR

  • Extract OpenCode host SDK fetch/baseUrl from nested plugin client services.
  • Use host-injected fetch for structured-output session requests when available.
  • Reset stale host fetch before configuring transport on plugin startup.
  • Fall back to global fetch with a warning log if host fetch cannot be discovered.
  • Call the host fetch with Request objects, matching the SDK fetch contract.
  • Preserve structured output generation by intentionally omitting noReply, since noReply suppresses assistant generation and prevents info.structured_output.
  • Support both info.structured_output and legacy info.structured.
  • Redact sensitive diagnostics from OpenCode HTTP failures:
  • strip query params from diagnostic URLs
  • redact response bodies
  • allowlist only safe assistant error fields
  • Skip capturing the plugin’s own structured-summary prompt echo to avoid self-referential memories.
  • Add auto-capture outcome logs for skipped and persisted captures.
  • Keep dist clean before builds while preserving the current scripts/copy-web-assets.mjs asset-copy path.
  • Add regression coverage for:
  • nested host fetch/baseUrl extraction
  • stale host fetch reset
  • fallback warning log
  • host fetch usage over global fetch
  • Request-based fetch invocation
  • no-noReply structured output requests
  • structured_output parsing
  • diagnostic redaction
  • summary prompt filtering
    Verification
    On this branch:
  • bun run typecheck
  • bun run format:check
  • bun run build && bun test
    Result:
    198 pass
    0 fail
    Also manually verified earlier that the fixed branch can persist auto-capture memory:
    Auto-capture memory persisted

GraDea and others added 6 commits July 8, 2026 11:02
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@GraDea GraDea force-pushed the pr-140-bypass-sdk branch from 89e8f4b to 56b7086 Compare July 8, 2026 10:04
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@GraDea GraDea requested review from tickernelz and x-Spartacus July 8, 2026 13:07
@GraDea GraDea marked this pull request as ready for review July 8, 2026 13:08
@GraDea

GraDea commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

@tickernelz @x-Spartacus, could you review the changes carefully

@tickernelz tickernelz merged commit cd18222 into main Jul 9, 2026
4 checks passed
@tickernelz

Copy link
Copy Markdown
Owner

Merged into main as part of the v2.19.0 batch release. Verified on the fully-merged tree: bun run typecheck, bun run build, and bun test (197 pass / 0 fail) all green. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants