Skip to content

feat(agent): add raw control sender - #789

Open
GregHolmes wants to merge 1 commit into
mainfrom
gh/agent-raw-control-sender
Open

GregHolmes wants to merge 1 commit into
mainfrom
gh/agent-raw-control-sender

Conversation

@GregHolmes

Copy link
Copy Markdown
Contributor

Summary

  • Add public sync and async send_raw() methods for protocol-transparent Agent control-frame bridges.
  • Serialize mapping inputs without model validation and preserve serialized JSON strings unchanged.
  • Freeze the generated socket-client patch and cover both input forms on both clients.

Closes #785

Validation

  • 32 tests in tests/custom/test_socket_client_shims.py
  • mypy src tests/typecheck/compat_aliases.py
  • ruff check on changed files
  • All validation ran in a clean Python 3.12 container

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Branch Rate Complexity Health
src.deepgram 97% 94% 0 ✔
src.deepgram.agent 100% 100% 0 ✔
src.deepgram.agent.v1 98% 100% 0 ✔
src.deepgram.agent.v1.settings 100% 100% 0 ✔
src.deepgram.agent.v1.settings.think 100% 100% 0 ✔
src.deepgram.agent.v1.settings.think.models 97% 100% 0 ✔
src.deepgram.auth 100% 100% 0 ✔
src.deepgram.auth.v1 100% 100% 0 ✔
src.deepgram.auth.v1.tokens 97% 100% 0 ✔
src.deepgram.core 88% 81% 0 ➖
src.deepgram.errors 100% 100% 0 ✔
src.deepgram.helpers 100% 95% 0 ✔
src.deepgram.listen 100% 100% 0 ✔
src.deepgram.listen.v1 98% 93% 0 ✔
src.deepgram.listen.v1.media 97% 100% 0 ✔
src.deepgram.listen.v2 98% 93% 0 ✔
src.deepgram.manage 100% 100% 0 ✔
src.deepgram.manage.v1 100% 100% 0 ✔
src.deepgram.manage.v1.models 96% 100% 0 ✔
src.deepgram.manage.v1.projects 97% 100% 0 ✔
src.deepgram.manage.v1.projects.billing 100% 100% 0 ✔
src.deepgram.manage.v1.projects.billing.balances 96% 100% 0 ✔
src.deepgram.manage.v1.projects.billing.breakdown 97% 100% 0 ✔
src.deepgram.manage.v1.projects.billing.fields 97% 100% 0 ✔
src.deepgram.manage.v1.projects.billing.purchases 97% 100% 0 ✔
src.deepgram.manage.v1.projects.keys 96% 100% 0 ✔
src.deepgram.manage.v1.projects.members 97% 100% 0 ✔
src.deepgram.manage.v1.projects.members.invites 96% 100% 0 ✔
src.deepgram.manage.v1.projects.members.scopes 96% 100% 0 ✔
src.deepgram.manage.v1.projects.models 96% 100% 0 ✔
src.deepgram.manage.v1.projects.usage 98% 100% 0 ✔
src.deepgram.manage.v1.projects.usage.breakdown 97% 100% 0 ✔
src.deepgram.manage.v1.projects.usage.fields 97% 100% 0 ✔
src.deepgram.read 100% 100% 0 ✔
src.deepgram.read.v1 100% 100% 0 ✔
src.deepgram.read.v1.text 98% 100% 0 ✔
src.deepgram.self_hosted 100% 100% 0 ✔
src.deepgram.self_hosted.v1 100% 100% 0 ✔
src.deepgram.self_hosted.v1.distribution_credentials 96% 100% 0 ✔
src.deepgram.speak 100% 100% 0 ✔
src.deepgram.speak.v1 98% 97% 0 ✔
src.deepgram.speak.v1.audio 91% 80% 0 ✔
src.deepgram.speak.v2 98% 93% 0 ✔
src.deepgram.speak.v2.audio 100% 100% 0 ✔
src.deepgram.voice_agent 100% 100% 0 ✔
src.deepgram.voice_agent.configurations 95% 100% 0 ✔
src.deepgram.voice_agent.variables 95% 100% 0 ✔
Summary 95% (6507 / 6822) 91% (1419 / 1552) 0 ✔

Scope: hand-maintained SDK logic. Fern-generated data models (types/, requests/), package __init__.py files, version.py, and the unused core/http_sse/ scaffolding are excluded — see .coveragerc. Unscoped whole-package coverage is ~70%.

@dg-coreylweathers dg-coreylweathers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approve with nits.

What this PR does
Adds public send_raw(message: Dict | str) on the sync and async Voice Agent socket clients so protocol-transparent bridges can forward any control frame without calling the private _send() (issue #785). Dicts are JSON-serialized; strings are sent byte-for-byte.

What I checked

  • Does it send unchanged? Yes: _send does json.dumps for dicts and passes strings straight to websocket.send; the four new tests capture exactly that, including that 44100.0 is not converted to an int.
  • Is the patch protected from regen? Yes: agent/v1/socket_client.py was already frozen; the PR adds the ledger bullet.
  • Gates in Docker: mypy clean, ruff clean on changed files, pytest 1038 passed.

Should-fix

  • send_raw appears only in the socket client, its tests, .fernignore, and AGENTS.md. Add a send_raw(message) line to the agent.v1 section of reference.md and a one-line mention in a voice-agent example or the skill file, otherwise bridge authors keep using _send().
  • State the number contract in the docstring: "Values are sent as given; whole-number floats are not converted to integers, so pass ints where the API expects them." That is what the tests pin and how it differs from the typed senders.

Nits: the Union[Dict, str] annotation is narrower than _send accepts (bytes also work), fine as the public contract. Needs a rebase: AGENTS.md/.fernignore conflict with main now, and after #797 lands agent/v1/socket_client.py is regenerated, so re-apply the two methods there.

This branch has not been deployed

No deployments
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.

feat(agent): expose a public sender for raw Voice Agent control frames

2 participants