Skip to content

feat: give invoke_runner and other framework entrypoint operations the CHAIN kind (RIUS-1877) - #249

Closed
PabloPardoGarcia wants to merge 1 commit into
mainfrom
pablo/rius-1877-invoke-entrypoints-chain
Closed

PabloPardoGarcia wants to merge 1 commit into
mainfrom
pablo/rius-1877-invoke-entrypoints-chain

Conversation

@PabloPardoGarcia

Copy link
Copy Markdown
Member

What

  • kindForOperation maps a gen_ai.operation.name that starts with invoke_ and is not in the kind-by-operation table to CHAIN. invoke_agent is in the table and stays AGENT; invoke_workflow stays CHAIN. A bare invoke_ (no entrypoint name) still has no kind. Same rule, order and guards as the Python SDK (rius-sdk-python#284).
  • src/semconv.generated.ts gains invoke_runner: CHAIN in KIND_BY_OPERATION, from rius-semconv #112.
  • Tests: kindForOperation for invoke_runner, an arbitrary invoke_crew, invoke_workflow, invoke_agent and look-alikes (invoke_, invoke, reinvoke_runner), and the normalizer putting CHAIN on a native span with an entrypoint operation.

Why

The OpenTelemetry GenAI conventions added framework-entrypoint operations in semantic-conventions-genai#571: invoke_runner, and invoke_{framework_entrypoint} in general. A native runner span therefore got no openinference.span.kind from the normalizer. The conventions define an entrypoint as not being an agent, so it is a CHAIN span, not AGENT. The family is open-ended, so a table cannot list it and the prefix rule lives in the helper.

Vendored file: re-sync before merge

The change to src/semconv.generated.ts is only the delta from rius-semconv #112, applied on top of the vendored v1.10.0 copy, so the semconv-vendored check fails on this branch until it is re-pinned. After #112 squash-merges and a rius-semconv release carries it, re-vendor with TAG=<that tag> scripts/sync-semconv.sh (that re-pin also brings in whatever v1.11 and v1.12 added).

Testing

  • npm run lint, npm run typecheck, npm run build, npm test (95 files, 2846 tests): all exit 0.
  • Mutation check: dropping the length guard fails 1 test (invoke_ would become CHAIN); dropping the prefix match fails 2 tests. Restored after each.
  • scripts/sync-semconv.sh --check: fails as expected (see above).

Related: RIUS-1877

…e CHAIN kind (RIUS-1877)

The GenAI conventions added framework-entrypoint operations (invoke_runner,
and invoke_{framework_entrypoint} in general) and define an entrypoint as not
being an agent. kindForOperation knew none of them, so a native runner span
got no openinference.span.kind.

The vendored kind-by-operation table gains invoke_runner from rius-semconv,
and kindForOperation maps any other invoke_ operation the table does not list
to CHAIN. invoke_agent stays AGENT and invoke_workflow stays CHAIN.
@PabloPardoGarcia

Copy link
Copy Markdown
Member Author

Automated review

No blocking issues.

Correctness. kindForOperation (src/semconv.ts:79) still uses Object.hasOwn on the table first, so the prototype-chain guard (toString, constructor) holds, invoke_agent stays AGENT, and invoke_workflow / invoke_runner come from the table. After that, startsWith("invoke_") && length > 7 gives CHAIN. It agrees with the Python SDK (#284) and the sink (argus-core#764) on every edge I checked: case-sensitive, bare invoke_ is unknown, no trimming ("invoke_ " is CHAIN in all three, " invoke_x" is unknown in all three), table-first ordering.

Callers. Every kind derived from the operation goes through kindForOperation: normalize.taxonomyFromOperation (src/normalize.ts:784) and compaction.ts:328. The latter only asks "is this LLM", so CHAIN changes nothing there. The remaining GEN_AI_OPERATION_NAME comparisons (aggregatedUsage.ts:84 for invoke_agent, nativeProviderSpans.ts:78 for chat, normalize.ts:1611 for the @ai-sdk/otel run) are exact-value checks, not kind derivation, so the fallback correctly doesn't touch them.

Vendored file. src/semconv.generated.ts equals rius-semconv v1.10.0 out/typescript/semconv.generated.ts plus exactly the rius-semconv#112 delta. I applied the patch to v1.10.0 and diffed: identical apart from the vendoring header. The failing vendored check fails only on that delta and clears once the module is re-pinned to the release that contains #112. Nothing else in the generated file was hand-edited.

Tests. tests/normalizeOpenInference.test.ts passes locally (136 tests). The new cases cover the table entry, the prefix fallback, invoke_agent, the near-misses and the normalized native span. The other CI jobs are green.

Nits

  • Consider one case-sensitivity case (kindForOperation("INVOKE_RUNNER") is undefined) so all three implementations stay pinned to the same rule.

@PabloPardoGarcia

Copy link
Copy Markdown
Member Author

Landed through #254, together with the rius-semconv v1.13.0 sync.

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