signalwire-sdk 3.7.3.dev135__py3-none-any.whl → 3.7.3.dev136__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
signalwire/__init__.py CHANGED
@@ -59,7 +59,7 @@ if TYPE_CHECKING:
59
59
  from signalwire.utils.schema_utils import SchemaValidationError
60
60
  from signalwire.web import WebService
61
61
 
62
- __version__ = "3.7.3.dev135"
62
+ __version__ = "3.7.3.dev136"
63
63
 
64
64
  # §6.2-python (owner decision: NO packaging split — one package, all deps required;
65
65
  # IMPORT-TIME behavior only): the agent/web symbols are lazy-imported via module
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [Unreleased]
4
+
5
+ ### Fixed
6
+ - In a chat session, the post-prompt summary is accepted. The chat service
7
+ fetches an agent's SWML under the conversation's id, so its tokens carry
8
+ that id, and posts the summary under its own runtime call id, with the
9
+ conversation's id as `conversation_id`. The SDK checked the token against
10
+ `call_id` only, so it refused every chat summary, retried until the service
11
+ gave up. A token is now accepted when it names the request's `call_id` or
12
+ its `conversation_id`, for the post-prompt and for secure functions alike;
13
+ a voice call, where the two are the same, is unchanged.
14
+
3
15
  ## [3.7.3] - 2026-10-19
4
16
 
5
17
  ### Added
@@ -68,7 +68,7 @@ class AgentServer:
68
68
  self.app = FastAPI(
69
69
  title="SignalWire AI Agents",
70
70
  description="Hosted SignalWire AI Agents",
71
- version="3.7.3.dev135",
71
+ version="3.7.3.dev136",
72
72
  redirect_slashes=False,
73
73
  docs_url=None,
74
74
  redoc_url=None,
@@ -175,6 +175,12 @@ def _slot_names(klass: type) -> list[str]:
175
175
  return names
176
176
 
177
177
 
178
+ def _conversation_id(body: Any) -> str | None:
179
+ """A request's ``conversation_id``, if it names one."""
180
+ value = body.get("conversation_id") if isinstance(body, dict) else None
181
+ return value if isinstance(value, str) and value else None
182
+
183
+
178
184
  class AgentBase( # type: ignore[misc] # intentional diamond: WebMixin's serve/_proxy_url_base override SWMLService/ServerlessMixin's by MRO order; mypy flags the base-vs-base shape diff but the resolution is deliberate
179
185
  AuthMixin,
180
186
  WebMixin,
@@ -1793,7 +1799,11 @@ class AgentBase( # type: ignore[misc] # intentional diamond: WebMixin's serve/
1793
1799
  )
1794
1800
 
1795
1801
  token = request.query_params.get("__token") or request.query_params.get("token")
1796
- rejection = target._tool_token_rejection(function_name, token, call_id)
1802
+ # conversation_id only when the request names one, so an override
1803
+ # written for the three-argument form keeps working
1804
+ conversation_id = _conversation_id(body)
1805
+ extra = {"conversation_id": conversation_id} if conversation_id else {}
1806
+ rejection = target._tool_token_rejection(function_name, token, call_id, **extra)
1797
1807
  if rejection is not None:
1798
1808
  return self, rejection
1799
1809
  return target, None
@@ -1825,7 +1835,11 @@ class AgentBase( # type: ignore[misc] # intentional diamond: WebMixin's serve/
1825
1835
  return target
1826
1836
 
1827
1837
  def _tool_token_rejection(
1828
- self, function_name: str, token: str | None, call_id: str | None
1838
+ self,
1839
+ function_name: str,
1840
+ token: str | None,
1841
+ call_id: str | None,
1842
+ conversation_id: str | None = None,
1829
1843
  ) -> dict[str, Any] | None:
1830
1844
  """Refuse a secure function's call unless it carries a valid token.
1831
1845
 
@@ -1836,10 +1850,16 @@ class AgentBase( # type: ignore[misc] # intentional diamond: WebMixin's serve/
1836
1850
  token. Every path that dispatches a SWAIG function, web server or
1837
1851
  serverless, checks it here.
1838
1852
 
1853
+ The token may name the request's ``call_id`` or its
1854
+ ``conversation_id``. A chat session fetches its SWML, and so gets its
1855
+ tokens, under the conversation's id, then sends every request under
1856
+ the chat service's own call id, with the conversation's id beside it.
1857
+
1839
1858
  Args:
1840
1859
  function_name: The function the request asks to run
1841
1860
  token: The token from the request's query string, if any
1842
1861
  call_id: The call the request belongs to, if known
1862
+ conversation_id: The request's ``conversation_id``, if any
1843
1863
 
1844
1864
  Returns:
1845
1865
  The SWAIG response to send instead of running the function, or
@@ -1860,7 +1880,16 @@ class AgentBase( # type: ignore[misc] # intentional diamond: WebMixin's serve/
1860
1880
  token
1861
1881
  and call_id is not None
1862
1882
  and hasattr(self, "_session_manager")
1863
- and self._session_manager.validate_tool_token(function_name, token, call_id)
1883
+ and (
1884
+ self._session_manager.validate_tool_token(function_name, token, call_id)
1885
+ or (
1886
+ conversation_id
1887
+ and conversation_id != call_id
1888
+ and self._session_manager.validate_tool_token(
1889
+ function_name, token, conversation_id
1890
+ )
1891
+ )
1892
+ )
1864
1893
  )
1865
1894
  if is_valid:
1866
1895
  req_log.debug("token_valid")
@@ -425,7 +425,15 @@ class ServerlessMixin(_HostTyped): # type: ignore[misc] # _HostTyped is object
425
425
  # and the token is checked against the agent that will run it
426
426
  call_id = _call_id(data)
427
427
  target = self._per_call_agent(query, data, headers)
428
- rejection = target._tool_token_rejection(function_name, token, call_id)
428
+ conversation_id = data.get("conversation_id")
429
+ # conversation_id only when the request names one, so an override
430
+ # written for the three-argument form keeps working
431
+ extra = (
432
+ {"conversation_id": conversation_id}
433
+ if isinstance(conversation_id, str) and conversation_id
434
+ else {}
435
+ )
436
+ rejection = target._tool_token_rejection(function_name, token, call_id, **extra)
429
437
  if rejection is not None:
430
438
  return 200, json.dumps(rejection)
431
439
 
@@ -1283,7 +1283,10 @@ class WebMixin(_HostTyped): # type: ignore[misc] # _HostTyped is object at run
1283
1283
  return 400, {"error": "The call_id in the URL and the body differ"}
1284
1284
  call_id = body_call_id or query_call_id
1285
1285
 
1286
- if not self._post_prompt_token_valid(token, call_id, req_log):
1286
+ conversation_id = body.get("conversation_id")
1287
+ if not isinstance(conversation_id, str) or not conversation_id:
1288
+ conversation_id = None
1289
+ if not self._post_prompt_token_valid(token, call_id, req_log, conversation_id):
1287
1290
  return 403, {"error": "Invalid or missing token"}
1288
1291
 
1289
1292
  # A per-call copy of the agent when dynamic configuration is set.
@@ -1321,9 +1324,16 @@ class WebMixin(_HostTyped): # type: ignore[misc] # _HostTyped is object at run
1321
1324
  return 200, {"success": True}
1322
1325
 
1323
1326
  def _post_prompt_token_valid(
1324
- self, token: str | None, call_id: str | None, req_log: Any
1327
+ self,
1328
+ token: str | None,
1329
+ call_id: str | None,
1330
+ req_log: Any,
1331
+ conversation_id: str | None = None,
1325
1332
  ) -> bool:
1326
- """True when ``token`` is the post-prompt token minted for ``call_id``."""
1333
+ """True when ``token`` is the post-prompt token minted for ``call_id``,
1334
+ or for ``conversation_id``: a chat session's SWML, and so its token, is
1335
+ made for the conversation, and its summary arrives under the chat
1336
+ service's own call id."""
1327
1337
  if not token:
1328
1338
  req_log.warning("token_missing")
1329
1339
  return False
@@ -1334,6 +1344,13 @@ class WebMixin(_HostTyped): # type: ignore[misc] # _HostTyped is object at run
1334
1344
  try:
1335
1345
  is_valid = bool(
1336
1346
  self._session_manager.validate_tool_token("post_prompt", token, call_id)
1347
+ or (
1348
+ conversation_id
1349
+ and conversation_id != call_id
1350
+ and self._session_manager.validate_tool_token(
1351
+ "post_prompt", token, conversation_id
1352
+ )
1353
+ )
1337
1354
  )
1338
1355
  except Exception as e:
1339
1356
  req_log.error("token_validation_error", error=str(e))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: signalwire-sdk
3
- Version: 3.7.3.dev135
3
+ Version: 3.7.3.dev136
4
4
  Summary: SignalWire SDK for AI voice agents, live call control (RELAY) and REST. Run sw-pydocs for its documentation.
5
5
  Author-email: SignalWire Team <info@signalwire.com>
6
6
  License: MIT
@@ -1,11 +1,11 @@
1
1
  signalwire/AGENTS.md,sha256=LUiIFwmtFMyeYj3BenEbE5GOMksddQwGWZbFLRiPQCY,490
2
- signalwire/__init__.py,sha256=nPaq_r62QIwm9IH7CUgTRUqSxq-W9kDlgHdFMu8Ucmk,8970
2
+ signalwire/__init__.py,sha256=w9eQm3eDb7upsEb_MYrFvzBWTukXD3CWndsWbJ78Syg,8970
3
3
  signalwire/__main__.py,sha256=lljoFxAAYSspcGSK4tXRo-vLoD4rXTipQMQhIuB9F90,346
4
- signalwire/agent_server.py,sha256=GDQ4gq-jdllmHENjASFnutJz5CEc2BCpe0Fljd9FuQI,31153
4
+ signalwire/agent_server.py,sha256=uw5tVNZsUqEOHLGY1hI3eED_jpYR1wdJfNf7uD-VsxQ,31153
5
5
  signalwire/llms.txt,sha256=Aif3UjUPY1HYSv7EWdMbLqfUONB4l_FSKKC8zDyjJw0,5799
6
6
  signalwire/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  signalwire/schema.json,sha256=rULmwiPr6KPIWdhPfxiguJFzXG7cdU9qgJuunijC0Bw,387544
8
- signalwire/_docs/CHANGELOG.md,sha256=RrGzFEz7DxRix2G8n6vIi2YYkoA-V7NS7L52_TVtEaA,48143
8
+ signalwire/_docs/CHANGELOG.md,sha256=4EUbajRl18NypuiRRVp-rWsIwd64DeSJfRDQ5enY3GI,48759
9
9
  signalwire/_docs/LICENSE,sha256=NYvAsB-rTcSvG9cqHt9EUHAWLiA9YzM4Qfz-mPdvDR0,1067
10
10
  signalwire/_docs/README.md,sha256=RjdHGNIESp6IUzOMS4oZnNNXj6TE77f959bCaX_j8DI,13289
11
11
  signalwire/_docs/docs/agent_guide.md,sha256=uwYG2BtWiRnp2J11fMa88aofd5xlf0-z5woBcjZYlG0,124847
@@ -245,7 +245,7 @@ signalwire/cli/simulation/mock_env.py,sha256=Whi818ckeC-dDyrsvraCz4bC9c57Zpc15XH
245
245
  signalwire/core/__init__.py,sha256=0swFd6mLunkuDvyrTMlAGm8wdS9e0sSlEGclw2CkLOM,2004
246
246
  signalwire/core/_agent_host.py,sha256=-zzMMlKroMsclPCSvUwqQtDwTBGcg2KV-3qDenfiPb8,1090
247
247
  signalwire/core/_sync_handlers.py,sha256=VRJ5o8uQFHcmg3zLHDXbHhIrI0HT5v9g_z22ejKpgLY,4081
248
- signalwire/core/agent_base.py,sha256=55ZC5gHRHkelnYQDDfhAV1rTMUDaFMRr-7DMBXgEBH4,96006
248
+ signalwire/core/agent_base.py,sha256=GzOEUGFX4P2OodMYNfoX6wDBolEIUNVRDbK5pDRy7No,97268
249
249
  signalwire/core/auth_handler.py,sha256=FBnfta2ykcDuSXCthgBJU0m5SFRi1l9llGxGSAocVeY,9211
250
250
  signalwire/core/capabilities.py,sha256=HAa-_yeJ4znApvtQ8ONFFHtG8nmxDZMs4BwqBSygdIs,4354
251
251
  signalwire/core/config_loader.py,sha256=lJ2WxZPTkyWR2ueJstRi8iKEkQXXav3w0Hiz5KKecNg,8631
@@ -288,11 +288,11 @@ signalwire/core/mixins/ai_config_mixin.py,sha256=7n4gBFOs5naBnHg8Uu9dcSgwYmQd7It
288
288
  signalwire/core/mixins/auth_mixin.py,sha256=NmmGoSuZ7e5dfVcqR_sq0xpFDK1uR-MKRTOkRuBTWuM,9191
289
289
  signalwire/core/mixins/mcp_server_mixin.py,sha256=I7sODR3wX89t5D3JvyX6zDBGvedg2orS5zJniSi73f0,6921
290
290
  signalwire/core/mixins/prompt_mixin.py,sha256=dyz0vexlUAjuIot1SUoThCBC1mqjdsT3IBbi0VhDOEk,15322
291
- signalwire/core/mixins/serverless_mixin.py,sha256=fcotItLfiUQhEVgoAdrCIbHwRdKqSbcS8sZZW6x7mtU,27041
291
+ signalwire/core/mixins/serverless_mixin.py,sha256=elPBOsgnkQv_sPPFNUVZ7uz7UI-cZPtStYH2q4h7fGg,27403
292
292
  signalwire/core/mixins/skill_mixin.py,sha256=hMBxH6SiouwAQa3HWpMlzOiuJh5wBtnlp-dEk4ACrzg,2471
293
293
  signalwire/core/mixins/state_mixin.py,sha256=-YR2YCC-siEjnJF6Wd_Tf8usjSzYVkUbEb3yzlQOwzU,6973
294
294
  signalwire/core/mixins/tool_mixin.py,sha256=9WlNDTCyDzS8l7QTmF-uEhPOm1hxI4hNbUAD9Otais0,17654
295
- signalwire/core/mixins/web_mixin.py,sha256=nbjSmw0EFj5XJ1R1l4LmFwbxCIXB_vGupLqKHy8BhXU,76606
295
+ signalwire/core/mixins/web_mixin.py,sha256=ux0mOSKDB4I5_mMvgd4L0tCBfdbtz2UsBsn8TtJJuP4,77315
296
296
  signalwire/core/security/__init__.py,sha256=3RhKvn6mI3DbnQ87XWdxwakNNGO8BCo1RxdlaGcE-J8,1061
297
297
  signalwire/core/security/security_utils.py,sha256=JATCCeMUSx8Xtich3boQpzcWTfyVgr5NoZpifAUvlqM,2981
298
298
  signalwire/core/security/session_manager.py,sha256=dRjQJgert79efpH2Swye4N6z-44O9_ooOceUcqzmzVA,9428
@@ -449,13 +449,13 @@ signalwire/utils/url_validator.py,sha256=LkND857aF-5_L1lZDTFAvr1wIjlcEHddpTvPDtV
449
449
  signalwire/utils/validators.py,sha256=N7XTtqhBblFn7N_hGcAvXjVFpGQ5scJuaOB1BRaVZ8s,180
450
450
  signalwire/web/__init__.py,sha256=EhmWx_9JkI9aMrByqWnh9DDZ7vESFVrgRYnYFtf_5dw,367
451
451
  signalwire/web/web_service.py,sha256=0fi4bWnGp0hDLGPOrGkeJ9vhuZsgJnEppnWu2m6yz_E,28780
452
- signalwire_sdk-3.7.3.dev135.data/data/share/man/man1/sw-agent-init.1,sha256=O3CsSJRhMN-jcOuwLhYl8AJl99FSOQFzCy1pd0eZczY,8533
453
- signalwire_sdk-3.7.3.dev135.data/data/share/man/man1/sw-pydocs.1,sha256=lTY1AFDwIUzrqaBhWPmXPmpNlx04TktkbhkPtYMAWTU,2491
454
- signalwire_sdk-3.7.3.dev135.data/data/share/man/man1/sw-search.1,sha256=IA71wy73FN23AKNVPylq1pHz8vuI1xaY1Osoh55zmX8,10398
455
- signalwire_sdk-3.7.3.dev135.data/data/share/man/man1/swaig-test.1,sha256=Ri0EITo8YMFowkcYltwPSwU4VJdRzo7XTWloi5WddCg,7815
456
- signalwire_sdk-3.7.3.dev135.dist-info/licenses/LICENSE,sha256=NYvAsB-rTcSvG9cqHt9EUHAWLiA9YzM4Qfz-mPdvDR0,1067
457
- signalwire_sdk-3.7.3.dev135.dist-info/METADATA,sha256=1vUrWuVNW6iqSYNldr3Zr-mU7-vdmCJyfWuELxItb0I,17920
458
- signalwire_sdk-3.7.3.dev135.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
459
- signalwire_sdk-3.7.3.dev135.dist-info/entry_points.txt,sha256=35JJ-BDhjlTRRZmBt05mBu9uF9loYRqXE0kDEvkbxm8,367
460
- signalwire_sdk-3.7.3.dev135.dist-info/top_level.txt,sha256=HRoWdnczdZfAdIYPOWpzceSUbq_sqL4RrwdsJdqnkEo,11
461
- signalwire_sdk-3.7.3.dev135.dist-info/RECORD,,
452
+ signalwire_sdk-3.7.3.dev136.data/data/share/man/man1/sw-agent-init.1,sha256=O3CsSJRhMN-jcOuwLhYl8AJl99FSOQFzCy1pd0eZczY,8533
453
+ signalwire_sdk-3.7.3.dev136.data/data/share/man/man1/sw-pydocs.1,sha256=lTY1AFDwIUzrqaBhWPmXPmpNlx04TktkbhkPtYMAWTU,2491
454
+ signalwire_sdk-3.7.3.dev136.data/data/share/man/man1/sw-search.1,sha256=IA71wy73FN23AKNVPylq1pHz8vuI1xaY1Osoh55zmX8,10398
455
+ signalwire_sdk-3.7.3.dev136.data/data/share/man/man1/swaig-test.1,sha256=Ri0EITo8YMFowkcYltwPSwU4VJdRzo7XTWloi5WddCg,7815
456
+ signalwire_sdk-3.7.3.dev136.dist-info/licenses/LICENSE,sha256=NYvAsB-rTcSvG9cqHt9EUHAWLiA9YzM4Qfz-mPdvDR0,1067
457
+ signalwire_sdk-3.7.3.dev136.dist-info/METADATA,sha256=FOMqm9WN0DnReDuERVRRiPLZuH5O78asCYXCaWyb4Y4,17920
458
+ signalwire_sdk-3.7.3.dev136.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
459
+ signalwire_sdk-3.7.3.dev136.dist-info/entry_points.txt,sha256=35JJ-BDhjlTRRZmBt05mBu9uF9loYRqXE0kDEvkbxm8,367
460
+ signalwire_sdk-3.7.3.dev136.dist-info/top_level.txt,sha256=HRoWdnczdZfAdIYPOWpzceSUbq_sqL4RrwdsJdqnkEo,11
461
+ signalwire_sdk-3.7.3.dev136.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (84.0.0)
2
+ Generator: setuptools (84.2.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5