-
Notifications
You must be signed in to change notification settings - Fork 478
feat(frontend): prefer x-agenta.flags.is_chat for chat variant detection #3690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/new-chat-interface
Are you sure you want to change the base?
feat(frontend): prefer x-agenta.flags.is_chat for chat variant detection #3690
Conversation
Update all 4 frontend chat detection paths to prefer the explicit x-agenta.flags.is_chat flag from the SDK's OpenAPI extension, falling back to the existing messages-property heuristic for older apps. Detection paths updated: - genericTransformer/index.ts: detectChatVariantFromOpenAISchema() - appRevision/api/schema.ts: extractAllEndpointSchemas() - appRevision + legacyAppRevision runnableSetup.ts: isChatVariantAtomFamily (now reads pre-computed isChatVariant from schema state) - requestSchemaMeta.ts: hasMessages computation Stacked on PR #3622 (SDK flags support).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…allback Fix pre-existing bug surfaced by this PR: ep?.messagesSchema !== null evaluates to true for null endpoints (undefined !== null is true), causing every app without the x-agenta flag to be detected as chat. Change to !!ep?.messagesSchema for correct truthiness check.
Testing ResultsDeployment: http://144.76.237.122:8180 What was tested
What's confirmed working
Additional tests needed
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| const hasMessages = Boolean(properties?.messages) | ||
| // Prefer explicit x-agenta.flags.is_chat, fall back to messages property heuristic | ||
| const flagValue = getIsChatFlag(spec as OpenAPISpec, routePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 getIsChatFlag ignores variant.routePath fallback used by getRequestSchema
When routePath param is undefined, getIsChatFlag builds paths without a route prefix (e.g., /run), but getRequestSchema falls back to (opts.variant as any)?.routePath (web/oss/src/lib/shared/variant/openapiUtils.ts:10). This means the two functions may look up different OpenAPI paths for the same call.
Root Cause
In requestSchemaMetaAtomFamily, both getRequestSchema and getIsChatFlag are called with the same routePath param:
const requestSchema = getRequestSchema(spec, {variant, routePath})
const flagValue = getIsChatFlag(spec, routePath)However, getRequestSchema internally resolves the route path as:
const routePath = opts.routePath ?? (opts.variant as any)?.routePathSo when routePath is undefined but variant.routePath has a value (e.g., "my-app/v1"), getRequestSchema correctly looks up /my-app/v1/run, while getIsChatFlag looks up /run — a path that likely doesn't exist in the spec. The flag lookup silently fails and returns undefined, causing the code to fall back to the heuristic.
Impact: The explicit x-agenta.flags.is_chat flag is silently ignored whenever routePath is undefined but variant.routePath is set. The heuristic fallback still produces correct results for older apps, but for apps relying on the new flag (e.g., chat variants without a messages property), this could yield an incorrect hasMessages: false.
| const flagValue = getIsChatFlag(spec as OpenAPISpec, routePath) | |
| const effectiveRoutePath = routePath ?? (variant as any)?.routePath | |
| const flagValue = getIsChatFlag(spec as OpenAPISpec, effectiveRoutePath) | |
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
x-agenta.flags.is_chatOpenAPI extension from the SDK, falling back to the existingmessages-property heuristic for older appsisChatVariantAtomFamilyin bothappRevisionandlegacyAppRevisionto read pre-computedisChatVariantfrom schema state instead of re-iterating endpointsDetection paths updated
genericTransformer/index.tsdetectChatVariantFromOpenAISchema()checksoperation["x-agenta"].flags.is_chatfirstappRevision/api/schema.tsextractAllEndpointSchemas()checks flag on all endpoints before heuristicappRevision/state/runnableSetup.tsschemaState.isChatVariant(already computed with flag priority)legacyAppRevision/state/runnableSetup.tsrequestSchemaMeta.tshasMessagesprefers flag, falls back toproperties.messagesStacked on
feat/new-chat-interface): SDKflagssupport +x-agenta.flagsOpenAPI extensionfeat/chat-interface-eval-detection): API evaluation chat detectionTesting
x-agenta.flags.is_chatin OpenAPI