4.2 KiB
semantic-scene Specification
Purpose
TBD - created by archiving change semantic-scene-runtime. Update Purpose after archive.
Requirements
Requirement: Semantic scene enrichment from an existing Scene
The system SHALL provide a function that, given an existing Scene (as produced by the scene-perception capability), produces a SemanticScene consisting of a page identity string, a list of plain-language supported intents, and a list of per-widget purpose labels referencing the Scene's element IDs, using exactly one LLM call.
Scenario: Enrichment succeeds for a recognizable screen
- WHEN
enrich_scene()is called with aScenedescribing a recognizable app screen (e.g. a chat screen with a text input and a send button) - THEN it returns a
SemanticScenewith a non-emptypagestring, a non-emptyintentslist of plain-language strings, and awidgetslist where each entry'selement_idmatches an element ID present in the inputScene
Scenario: Widget purpose labels reference only known elements
- WHEN the LLM response includes a widget purpose label whose
element_iddoes not match any element ID in the inputScene - THEN
enrich_scene()discards that widget entry from the returnedSemanticScenerather than propagating a dangling element reference
Requirement: Enrichment failure degrades to no semantic scene, never blocks the loop
The system SHALL treat any enrichment failure (LLM call timeout, connection error, rate limit, malformed or schema-invalid response, or enrichment disabled by configuration) as a non-fatal condition, returning an absence of a semantic scene rather than raising an exception, so that callers always have a defined fallback of using the raw Scene.
Scenario: LLM call times out
- WHEN the enrichment LLM call does not complete within the configured timeout
- THEN
enrich_scene()returnsNoneand the caller proceeds using the rawScenewithout the task step being marked as failed
Scenario: LLM response fails schema validation
- WHEN the enrichment LLM call returns a response that does not conform to the expected
SemanticSceneJSON schema - THEN
enrich_scene()returnsNoneinstead of raising, and no partially-parsedSemanticSceneis returned
Scenario: Enrichment disabled by configuration
- WHEN semantic enrichment is disabled in configuration
- THEN
enrich_scene()returnsNoneimmediately without making an LLM call
Requirement: Structured, schema-constrained LLM output
The system SHALL request the enrichment LLM call using a schema-constrained structured-output mechanism so that any successful response is guaranteed to be valid JSON matching the SemanticScene shape, rather than relying on free-text parsing of an unconstrained model reply.
Scenario: Successful call yields directly parseable output
- WHEN the enrichment LLM call completes successfully
- THEN the raw response body is valid JSON matching the declared
SemanticSceneschema without requiring text extraction, regex matching, or a JSON-repair step
Requirement: Semantic enrichment is opt-in and does not alter existing tool behavior
The system SHALL expose semantic enrichment through a new, separate tool entry point rather than modifying the existing describe_screen tool's signature or behavior, so that every existing caller of describe_screen continues to receive only a Scene, unchanged, unless it explicitly opts into the new semantic-enriched entry point.
Scenario: Existing describe_screen callers are unaffected
- WHEN an existing caller invokes the
describe_screentool as it did before this change - THEN it receives the same
Sceneresult as before, with no semantic enrichment attempted and no new LLM-related dependency invoked
Scenario: A caller opts into semantic enrichment
- WHEN a caller invokes the new semantic-enrichment tool entry point for a given device
- THEN it receives both the underlying
Sceneand, when enrichment succeeds, the correspondingSemanticScene; when enrichment fails or is disabled, it receives theScenewith an explicit absence of aSemanticScenerather than a partial or error result