Skip to content

[WIP] feat: support bfclv4#178

Open
123liuziming wants to merge 3 commits intomainfrom
feat/bfclv4
Open

[WIP] feat: support bfclv4#178
123liuziming wants to merge 3 commits intomainfrom
feat/bfclv4

Conversation

@123liuziming
Copy link
Copy Markdown
Collaborator

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

musi and others added 2 commits May 6, 2026 18:38
…ard v4

Introduce loongsuite-instrumentation-bfclv4 covering BFCL v4 (bfcl_eval) per
the design in llm-dev/bfclv4/execute.md:

* ENTRY span around bfcl_eval._llm_response_generation.generate_results,
  with a narrow swap of that module's ThreadPoolExecutor name to a
  contextvars-propagating subclass so worker threads inherit the ENTRY
  trace context.
* AGENT span around BaseHandler.inference (kind=AGENT, op=invoke_agent),
  picking up token usage from the metadata BFCL writes back.
* STEP spans created reflectively for every concrete handler discovered
  via bfcl_eval.constants.model_config.MODEL_CONFIG_MAPPING; each STEP
  re-invokes the handler's _parse_query_response_* to harvest token
  counts and latency.
* Per-call TOOL spans emitted from
  bfcl_eval.eval_checker.multi_turn_eval.multi_turn_utils.execute_multi_turn_func_call
  (one span per func_call entry in the batch).
* Provider override mapping that routes OSSMODEL handlers to vllm/sglang
  based on args.backend, plus contextvars-based bfcl.turn_idx /
  gen_ai.react.round tracking.

LLM spans are intentionally not created by this plugin; they continue to
be produced by the downstream vendor SDK probes (OpenAI / Anthropic /
DashScope / etc.).
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


musi seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

… responses

When ``_query_FC`` / ``_query_prompting`` returns a streaming wrapper
(e.g. ``openai-v2`` ``ChatStreamWrapper``), the LLM span and its OTel
context attach are kept alive until the stream is consumed by BFCL's
``_parse_query_response_*`` after the STEP context manager has already
exited. Non-LIFO context detach then leaves the prior LLM span as the
"current" span, which causes subsequent STEP and TOOL spans to be
parented under the previous STEP rather than under AGENT.

Force-consume the streaming response inside the STEP context and
replace it with a plain iterator over the cached chunks so that
``stop_llm`` (which detaches LLM context) runs in LIFO order before
STEP detaches.
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.

4 participants