Skip to content

refactor(core): assemble context and task prompts at model boundaries - #3429

Merged
EAGzzyCSL merged 3 commits into
mainfrom
zzy/multimodal-input-boundaries
Nov 25, 2026
Merged

EAGzzyCSL merged 3 commits into
mainfrom
zzy/multimodal-input-boundaries

Conversation

@EAGzzyCSL

Copy link
Copy Markdown
Collaborator

Summary

Keep the user's original instruction, reference images, and image conversion options together through the task and service layers. Pass supplemental context separately and assemble model-facing prompts at the model workflow boundary, including deepLocate's search-area step. Move Boolean, Assert, WaitFor, Number, and String demand formatting into the extraction workflow.

Previously, merging context or task-specific wording into prompts early made the same prompt field mean different things at different layers. Reports then needed a separate promptDisplay field to recover the original description.

Why this change

  1. Reports can use the original input directly. Titles and element descriptions use the original prompt text; structured aiQuery demands are serialized as JSON. Remove the extra locate promptDisplay field.
  2. Cache matching is independent of model prompt formatting. Generate locate cache keys separately while preserving their existing representation, and skip key generation when caching is disabled. Model message layout and context formatting can evolve without coupling those changes to cache matching.
  3. Model workflows control how context is consumed. Upstream layers pass the instruction and context separately. Each model workflow assembles its text or structured request without having to unpack a pre-composed prompt.
  4. Future context extensions have a clear boundary. Image context and shared history can later be introduced through explicit inputs and model-side assembly rather than being embedded in the instruction during task execution. This PR keeps context text-only and does not add history sharing.

This is a data-flow refactor, not a model-quality or cache-hit-rate optimization. Public context options remain unchanged, and existing model-facing context formatting is preserved.

Validation

  • pnpm run lint
  • pnpm exec nx test @midscene/core --output-style=static — 3,035 tests passed.
  • pnpm exec nx test @midscene/core --output-style=static -- tests/unit-test/service-locate-deeplocate.test.ts tests/unit-test/locate-prompt-order.test.ts — 29 tests passed after aligning search-area context assembly.
  • pnpm exec nx test @midscene/web --output-style=static -- tests/unit-test/page-task-executor-waitFor.test.ts — 2 tests passed.
  • pnpm exec tsc -p packages/core/tsconfig.json --noEmit --pretty false
  • pnpm exec nx build @midscene/core --output-style=static

Real-model tests were not run. The initial core test run overlapped with a build and encountered two report CLI artifact-loading failures; rerunning after the build passed all tests.

@EAGzzyCSL
EAGzzyCSL force-pushed the zzy/multimodal-input-boundaries branch from 297868b to da34d11 Compare November 25, 2026 06:16
@EAGzzyCSL
EAGzzyCSL merged commit 51c3046 into main Nov 25, 2026
30 of 32 checks passed
@EAGzzyCSL
EAGzzyCSL deleted the zzy/multimodal-input-boundaries branch November 25, 2026 08:41
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