Skip to content

fix: inject affinity metadata on simple completion calls - #21

Merged
rjcloudsigma merged 1 commit into
mainfrom
fix/simple-completion-affinity
Jul 28, 2026
Merged

fix: inject affinity metadata on simple completion calls#21
rjcloudsigma merged 1 commit into
mainfrom
fix/simple-completion-affinity

Conversation

@rjcloudsigma

Copy link
Copy Markdown
Collaborator

Root cause

The Snowcrash Server key had two simultaneous populations:

  • plugin-wrapped full agent/tool runs: correlation metadata + stable oc: identity
  • identity-less internal/background/simple completions: no metadata, fresh TaaS session per request

Both originate in the same OpenClaw gateway and use the same API key. The identity-less population was not Alien Studio or another host.

The plugin registered only wrapStreamFn. OpenClaw routes simple/internal/background completions through a separate runtime hook, wrapSimpleCompletionStreamFn, which therefore bypassed all affinity injection.

Fix

Register the existing buildWrapper on both surfaces. It injects identical metadata.session_id, metadata.sticky_key, requester runtime, and openclaw_correlation fields.

The runtime supports this hook; the currently installed plugin SDK type declaration lags the optional field, so a narrowly scoped compatibility cast is used at registration only.

Verification

  • New simple-completion regression test drives the exact hook and asserts generated oc: session/sticky identity plus agent_id correlation.
  • 17/17 plugin tests pass; TypeScript build clean.
  • No change to native-session precedence or no-identity behaviour.

@rjcloudsigma
rjcloudsigma merged commit befec92 into main Jul 28, 2026
1 check passed
@rjcloudsigma
rjcloudsigma deleted the fix/simple-completion-affinity branch July 28, 2026 18:33
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.

1 participant