Skip to content

bug: voice tool calls fail — wrong kwargs passed to PlatformAuditService.log() #705

Closed

Description

@vybe

Summary

Every canvas panel tool call made during a voice session fails with a TypeError. The voice WebSocket handler calls platform_audit_service.log() with actor_type=, actor_id=, and actor_email= keyword arguments that do not exist in the method's signature. The audit call raises immediately, aborting the tool execution. Canvas panel operations (file edits, code generation, etc.) are completely non-functional in voice mode.

Component

Backend / Voice Chat (VOICE-001) / Platform Audit Service (SEC-001)

Priority

P1

Error

ERROR services.gemini_voice: Voice tool call error: PlatformAuditService.log() got an unexpected keyword argument 'actor_type'

Appears on every canvas tool invocation during a voice session.

Location

  • File: src/backend/routers/voice.py
  • Lines: ~311–320 — await platform_audit_service.log(...) in on_tool_call callback

Root Cause

The voice router was written against a non-existent platform_audit_service.log() API. The actual signature accepts actor_user (a Pydantic User model), actor_agent_name, or actor_ip to identify the actor — it derives AuditActorType internally. The voice code instead passes actor_type=AuditActorType.USER, actor_id=, and actor_email= which are all invalid keyword arguments.

Actual log() signature (src/backend/services/platform_audit_service.py:70):

async def log(
    self,
    event_type: AuditEventType,
    event_action: str,
    source: str,
    *,
    actor_user: Optional[Any] = None,        # Pydantic User model
    actor_agent_name: Optional[str] = None,
    actor_ip: Optional[str] = None,
    ...
)

Voice router call (src/backend/routers/voice.py:~311):

await platform_audit_service.log(
    event_type=AuditEventType.EXECUTION,
    event_action="voice_tool_call",
    actor_type=AuditActorType.USER,    # ← does not exist
    actor_id=str(session.user_id),     # ← does not exist
    actor_email=session.user_email,    # ← does not exist
    target_type="agent",
    target_id=session.agent_name,
    details={"tool": tool_name, "prompt_preview": ...},
    source="api",
)

Reproduction Steps

  1. Deploy f7450ca
  2. Successfully open a voice session WebSocket (may require retries due to bug: voice WebSocket 403 — in-memory session lost across Uvicorn workers #704)
  3. Ask the agent to perform any canvas panel action (write a file, edit code, etc.)
  4. Observe TypeError in backend logs; tool result is never delivered

Suggested Fix

Replace the non-existent kwargs with the correct actor_user pattern. The user object is already resolved earlier in the WebSocket handler:

# In on_tool_call callback in voice_websocket(), replace:
await platform_audit_service.log(
    event_type=AuditEventType.EXECUTION,
    event_action="voice_tool_call",
    actor_type=AuditActorType.USER,
    actor_id=str(session.user_id),
    actor_email=session.user_email,
    target_type="agent",
    target_id=session.agent_name,
    details={"tool": tool_name, "prompt_preview": str(args.get("prompt", ""))[:100]},
    source="api",
)

# With:
await platform_audit_service.log(
    event_type=AuditEventType.EXECUTION,
    event_action="voice_tool_call",
    source="api",
    actor_user=user,               # 'user' dict already fetched during WS auth
    target_type="agent",
    target_id=session.agent_name,
    details={"tool": tool_name, "prompt_preview": str(args.get("prompt", ""))[:100]},
)

Note: actor_user expects the user dict/model returned by db.get_user_by_username().

Environment

  • Trinity version: f7450ca (feat(voice): agent workspace + canvas panel)

Related

Activity

  1. vybe commented on May 7, 2026

    @vybe
    ContributorAuthor

    /claim

  2. added
    status-in-progress
    on May 7, 2026
  3. github-actions commented on May 7, 2026

    @github-actions

    Claimed by @vybe. Label status-in-progress added.

    Next steps:

    1. Create branch: feature/705-<short-slug>
    2. Implement the feature
    3. Open a PR with Fixes #705
  4. added
    status-in-dev
    and removed
    status-in-progress
    on May 7, 2026
  5. vybe commented on May 10, 2026

    @vybe
    ContributorAuthor

    Fixed in PR #706 (e17ac8f on dev). Wrong kwargs to PlatformAuditService.log() corrected alongside the #704 fix.

  6. reopened this on May 10, 2026
  7. vybe commented on Jun 1, 2026

    @vybe
    ContributorAuthor

    Shipped in v0.6.0 (released via #998).

  8. removed
    status-in-dev
    on Jun 1, 2026
  9. added a commit that references this issue on Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority-p1type-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions