Skip to content

fix(funcs): forward embedding callback context consistently - #899

Merged
dosco merged 1 commit into
ax-llm:mainfrom
Elon-Jiang:fix/embedding-adapter-callback-context
Nov 16, 2026
Merged

dosco merged 1 commit into
ax-llm:mainfrom
Elon-Jiang:fix/embedding-adapter-callback-context

Conversation

@Elon-Jiang

Copy link
Copy Markdown
Contributor
  • What kind of change does this PR introduce?

    Bug fix for AxEmbeddingAdapter tool callbacks.

  • What is the current behavior?

    A callback such as async (embedding, options = {}) => search(embedding, options.sessionId) never receives the caller's options. The adapter forwards them only when func.length === 2; JavaScript's function length excludes default and rest parameters. A normal callback with a default options argument has length 1, while a rest callback has length 0. Both lose the session ID and abort signal supplied to the exported tool.

  • What is the new behavior (if this is a feature change)?

    Invoke the callback with the embedding and optional context according to its existing typed signature. Callbacks that only consume the embedding continue working; omitted context still activates the callback's default options.

  • AxIR portable behavior check:

    This touches handwritten src/ax/funcs/embed.ts and its new embed.test.ts, outside the paths requiring AxIR backlog enrollment. npm run axir:backlog:check -- --base origin/main --head HEAD passes without a new entry. No generated source, public signature, configuration or documentation is changed.

  • Other information:

    On main 007ab8366e5bfa98d871feb1af188cc029295c58, the public AxEmbeddingAdapter.toFunction().func regression gives 3 failures / 3 controls. After the fix all 6 pass. It covers default/rest/destructured parameters, ordinary two-parameter callbacks, one-parameter callbacks and omitted context.

    • Related callback/function tests: 17 passed.
    • Full Ax unit suite: 4,154 passed, 4 skipped (npm run test:unit --workspace=@ax-llm/ax -- --maxWorkers=2).
    • Ax TypeScript check and package build pass.
    • Changed-file Biome, cspell, actual pre-commit hook and git diff --check pass.

    The public adapter/tool code is real. AxMockAIService supplies deterministic embedding vectors in place of a provider; no external model or embedding request was made.

    AI assistance (Codex) was used for investigation, implementation, review and validation. No human code review is claimed.

@dosco
dosco merged commit 71372a3 into ax-llm:main Nov 16, 2026
15 checks passed
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