Skip to content

fix(service-ai): resolve current object for AI chat across languages#1815

Merged
xuyushun441-sys merged 2 commits into
mainfrom
fix/ai-current-object-resolution
Jun 13, 2026
Merged

fix(service-ai): resolve current object for AI chat across languages#1815
xuyushun441-sys merged 2 commits into
mainfrom
fix/ai-current-object-resolution

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Problem

On a runtime object page (e.g. …/showcase_app/showcase_task), asking the console assistant to analyse this object returned "can't find the X object" — most visibly for non-English prompts. Three compounding gaps:

  1. CJK dropped at tokenisationSchemaRetriever.tokenise() matched only [a-z0-9]+, so a Chinese request (分析任务对象) produced zero terms → query_data returned "No matching objects in metadata".
  2. No schema-discovery tool in the open editiondescribe_object/list_objects are cloud-only (@objectstack/service-ai-studio), leaving query_data's keyword match as the only object-resolution path.
  3. Current object never reached the agent — nothing fed the open object's schema into the prompt, so "this object" couldn't resolve without a lucky keyword hit.

Changes

  • schema-retriever.tstokenise() now emits CJK single-char + bigram terms alongside Latin/digit runs.
  • agent-runtime.ts — new buildContextSchemaMessages() looks up context.objectName and injects its schema into the system prompt, so "analyse this object" works with zero tool calls in any language. Both chat routes call it.
  • spec ToolExecutionContext gains currentObjectName/currentViewName; agent-routes.ts + assistant-routes.ts thread them through, and query_data falls back to the current object when keyword retrieval is empty.

Pairs with objectui fix/ai-current-object-context, which sends context.objectName from the current console route.

Tests

New coverage: CJK retrieval, schema injection (4 cases), query_data current-object fallback (2 cases). 81 service-ai tests pass; spec + service-ai build clean.

🤖 Generated with Claude Code

The console assistant reported "can't find the X object" when asked to
analyse the object on the current page — most visibly for non-English
prompts. Three compounding gaps:

- The keyword SchemaRetriever tokeniser dropped all CJK text, so a
  Chinese request yielded zero terms and "No matching objects".
- describe_object/list_objects are cloud-only, leaving query_data's
  keyword match as the only object-discovery path in the open edition.
- Nothing fed the current object's schema to the agent, so "this object"
  couldn't be resolved without a lucky keyword hit.

Changes:
- SchemaRetriever.tokenise() now emits CJK single-char + bigram terms.
- AgentRuntime.buildContextSchemaMessages() injects the current object's
  schema into the system prompt; both chat routes call it.
- ToolExecutionContext gains currentObjectName/currentViewName; routes
  thread them through and query_data falls back to the current object
  when keyword retrieval is empty.

Tests cover CJK retrieval, schema injection (4 cases), and the
query_data current-object fallback (2 cases). 81 service-ai tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 13, 2026 1:34pm

Request Review

…ck runtime

The mock AgentRuntime in agent-chat-quota.test.ts didn't implement the new
buildContextSchemaMessages method, so the route's await on it threw and the
handler returned 500 instead of 200. Mirror the real runtime in the mock.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@xuyushun441-sys
xuyushun441-sys merged commit b9ceaa4 into main Jun 13, 2026
12 checks passed
@xuyushun441-sys
xuyushun441-sys deleted the fix/ai-current-object-resolution branch June 13, 2026 13:41
os-zhuang added a commit that referenced this pull request Jun 20, 2026
objectui #1815 fixed page:card-in-region (the layout div was shadowing the
real renderer). Restore the My Work sidebar to use `page:card`:
  • a Shortcuts card (title + children list);
  • an admin-only Leadership card gated by `visible: user.email == …`.
Both render title + body and the role gate hides for non-matching users.

Browser-verified on :5181.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants