Skip to content

Commit 31a8bc8

Browse files
JarbasAlclaude
andcommitted
feat: skill_will_match accepts a Session to probe under that session's context
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 22116a4 commit 31a8bc8

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

ovos_workshop/skills/ovos.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,28 +2328,35 @@ def enable_intent(self, intent_name: str) -> bool:
23282328

23292329
def skill_will_match(self, utterance: str, lang: Optional[str] = None,
23302330
timeout: float = 0.8,
2331-
exclude_pipeline: Optional[List[str]] = None) -> bool:
2331+
exclude_pipeline: Optional[List[str]] = None,
2332+
session: Optional[Session] = None) -> bool:
23322333
"""Ask the intent service whether one of THIS skill's intents would match
2333-
the utterance under the current session context.
2334+
the utterance under a given session's context.
23342335
23352336
Uses the read-only `intent.service.intent.get` probe (it never executes a
2336-
handler, so it has no side effects). Honours the active session intent
2337-
context, so context-gated intents are accounted for.
2337+
handler, so it has no side effects). The probe runs under `session`'s
2338+
intent context, so context-gated intents (e.g. layer-gated game intents)
2339+
are accounted for per-session — essential when several sessions are active
2340+
at once.
23382341
23392342
@param utterance: utterance to probe
23402343
@param lang: language tag (defaults to skill lang)
23412344
@param timeout: seconds to wait for the intent-service reply
23422345
@param exclude_pipeline: pipeline stages to skip for this probe (substring
23432346
match). A skill that is currently conversing should pass
23442347
`["converse"]` to avoid re-entering its own converse stage.
2348+
@param session: the Session whose intent context to probe under; defaults
2349+
to the current/default session.
23452350
@return: True if the matched intent belongs to this skill
23462351
"""
23472352
lang = standardize_lang_tag(lang or self.lang)
2353+
session = session or SessionManager.get()
23482354
data = {"utterance": utterance, "lang": lang}
23492355
if exclude_pipeline:
23502356
data["exclude_pipeline"] = list(exclude_pipeline)
23512357
response = self.bus.wait_for_response(
2352-
Message("intent.service.intent.get", data),
2358+
Message("intent.service.intent.get", data,
2359+
{"session": session.serialize(), "lang": lang}),
23532360
"intent.service.intent.reply", timeout=timeout)
23542361
if not response:
23552362
return False

0 commit comments

Comments
 (0)