Skip to content

Read Tool & Reasoning Tokens from GenAI API instead of Catalog Metadata#838

Draft
sayanshaw24 wants to merge 2 commits into
mainfrom
sayanshaw/fl-tool-tags
Draft

Read Tool & Reasoning Tokens from GenAI API instead of Catalog Metadata#838
sayanshaw24 wants to merge 2 commits into
mainfrom
sayanshaw/fl-tool-tags

Conversation

@sayanshaw24

Copy link
Copy Markdown

Read tool calling and reasoning tokens from GenAI model API

Summary

Updates BuildToolCallContext() to read tool call and reasoning marker tokens from GenAI's OgaModel::GetGenerationTag() API introduced in this PR, instead of catalog metadata.

Changes

GenAIModelInstance (genai_model_instance.h / .cc)

  • New std::string GetGenerationTag(const char* tag_name) const method
  • Wraps OgaModel::GetGenerationTag() — returns the tag value or empty string

ChatSession::BuildToolCallContext() (chat_session.cc)

  • Removed all reads from CatalogModel().Info() for tool/reasoning tokens and support flags
  • Added GenAI API as the source (after request options)
  • supports_tool_calling / supports_reasoning are now inferred from non-empty start tokens

Resolution priority

Priority Source Notes
1 Request options Per-request override via FOUNDRY_LOCAL_MODEL_PROP_* params
2 GenAI model API Reads genai_config.json with model-family fallback map

Catalog metadata is no longer consulted for these tokens.

Dependency

Requires updated onnxruntime-genai nuget with OgaModelGetGenerationTag API.

  • GenAI PR
  • deps_versions.json bump needed once GenAI nuget publishes

Tag names supported by the GenAI API

  • "tool_call_start", "tool_call_end" — tool call delimiters
  • "reasoning_start", "reasoning_end" — chain-of-thought reasoning delimiters

Testing

Will be validated end-to-end once the GenAI nuget is available. The code change is minimal and mechanical — replaces catalog reads with GenAI API calls using the same field names.

@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foundry-local Ready Ready Preview, Comment Jun 26, 2026 6:35pm

Request Review

tool_ctx.supports_tool_calling = true;
}

// Fall back to GenAI model API (reads genai_config.json + model-family fallback map)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a little clunky to have a bunch of metadata coming from the catalog and some from the genai_config.json but we only merge those when creating a session.

Should we instead when populating the catalog models update the ModelInfo for a cached model to incorporate metadata from genai_config.json at that point? Same process post-download of a new model. That way all the other code doesn't need to know/care about the multiple sources of metadata - the just use the ModelInfo as-is.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Refactored in the latest commit. Model::Load() now populates ModelInfo with tool/reasoning tags from the GenAI model immediately after loading. BuildToolCallContext() is unchanged; it just reads from ModelInfo as before. Downstream code doesn't need to know about multiple metadata sources anymore.

return *oga_model_;
}

std::string GenAIModelInstance::GetGenerationTag(const char* tag_name) const {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: GetTag would be more generic unless there's an expected use-case where we would need to separate 'generation' tags from others. I assume the tag name could provide any separation required though.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, renamed to GetTag in both GenAI and FL. just need to update the GenAI version here in FL once the PR is merged and included.

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