Skip to content

docs(events): remove non-existent phone.events; document real API#114

Merged
nicolotognoni merged 1 commit into
PatterAI:mainfrom
knowsuchagency:docs/events-no-phone-events
May 27, 2026
Merged

docs(events): remove non-existent phone.events; document real API#114
nicolotognoni merged 1 commit into
PatterAI:mainfrom
knowsuchagency:docs/events-no-phone-events

Conversation

@knowsuchagency
Copy link
Copy Markdown
Contributor

Summary

  • The events page advertised phone.events.on(PatterEventType.X, handler) for fine-grained pipeline observability. Patter exposes no events attribute — the EventBus is instantiated per-StreamHandler (stream_handler.py:517), so the example raises AttributeError: 'Patter' object has no attribute 'events' immediately.
  • Replace the ## EventBus section with documentation of the APIs that actually exist on Patter:
    • Speech-edge events — attribute setters on Patter (on_user_speech_eos, on_agent_speech_ended, on_llm_token, etc.).
    • Tool events via on_transcript — tool invocations surface through the existing on_transcript callback with role="tool" plus tool_name / tool_args / tool_result.

Closes #112.

Why

Docs-only fix; no code change. The previous example is impossible to run as written, so any user who pasted it hit a hard AttributeError before placing a call.

A follow-up PR could implement Patter.events as a real public proxy to the in-flight StreamHandler._event_bus. That's left out of scope here — the priority was to stop publishing a broken example.

Test plan

  • grep -n "phone\\.events" docs/ returns no hits in the SDK docs
  • All documented attribute setters (phone.on_user_speech_*, phone.on_agent_speech_*, phone.on_llm_token, phone.on_audio_out) verified to exist on the Patter class (proxy via self.speech_events at libraries/python/getpatter/client.py:351-372)
  • on_transcript tool-event payload verified against StreamHandler._emit_tool_event at libraries/python/getpatter/stream_handler.py:929-960

The events page advertised `phone.events.on(PatterEventType.X, handler)`
for fine-grained pipeline observability, but `Patter` exposes no
`events` attribute — the `EventBus` is instantiated per-StreamHandler
(`stream_handler.py:517`), so the documented example raises
`AttributeError: 'Patter' object has no attribute 'events'` immediately.

Replace the section with documentation of the APIs that actually exist:

- **Speech-edge events** — attribute setters on `Patter`
  (`on_user_speech_eos`, `on_agent_speech_ended`, `on_llm_token`, etc.)
  that proxy to the per-process `SpeechEvents` dispatcher.
- **Tool events via `on_transcript`** — tool invocations surface through
  the existing `on_transcript` callback with `role="tool"` and an extra
  `tool_name` / `tool_args` / `tool_result` payload (see
  `StreamHandler._emit_tool_event` at `stream_handler.py:929`).

Closes PatterAI#112.
@nicolotognoni nicolotognoni self-assigned this May 27, 2026
@nicolotognoni nicolotognoni merged commit 9862623 into PatterAI:main May 27, 2026
9 checks passed
nicolotognoni added a commit that referenced this pull request May 27, 2026
…115) (#118)

- Pipeline mode in `libraries/typescript/src/stream-handler.ts` did not
  inject the built-in `transfer_call` / `end_call` tools into the
  `LLMLoop` (both `new LLMLoop(...)` call sites at lines 1891 and 1906
  passed `agent.tools` through unchanged). The Realtime path injects
  them at `server.ts:374`; pipeline was missing the parity. Added
  `augmentWithBuiltinHandoffTools` helper mirroring the Python helper
  shipped in #115; it builds handler closures that validate E.164 /
  default `reason` and dispatch to the existing telephony bridge
  methods (`bridge.transferCall` / `bridge.endCall`). Built-ins are
  skipped when the corresponding callback is missing, keeping
  non-telephony test harnesses clean. Exported
  `TRANSFER_CALL_TOOL` / `END_CALL_TOOL` from `server.ts` so the
  helper can re-use the canonical schema.
- Docs: `docs/typescript-sdk/events.mdx` advertised the same
  non-existent `phone.events.on(PatterEventType.X, handler)` API as
  the Python events page (closed by #114). Replaced the broken
  `EventBus` section with documentation of the APIs that actually
  exist on the TypeScript `Patter` class: speech-edge attribute
  setters (`onUserSpeechStarted` / `onAgentSpeechEnded` /
  `onLlmToken` / `onAudioOut` etc.) and tool events via
  `onTranscript` with `role === "tool"`.
- CHANGELOG: backfilled `## Unreleased` `### Fixed` entries for
  upstream PRs #113, #114, #115 (Python fixes by @knowsuchagency that
  landed without the corresponding TypeScript / changelog updates),
  plus entries for the two TypeScript parity fixes shipped here.

Test plan:
- Python: covered by tests added in the upstream PRs (#113, #115).
- TypeScript: 8 new unit tests in
  `libraries/typescript/tests/pipeline-builtin-tools.test.ts` cover
  empty-user-tools, non-empty user tools order, missing-callback
  skip, transfer dispatch + E.164 rejection, end_call default and
  user-supplied `reason`. Full suite: 1521 passed / 8 skipped, lint
  clean, build green.
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.

[BUG] Docs at docs.getpatter.com/python-sdk/events show phone.events.on(...) but the runtime has no such attribute

2 participants