Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

ToolFlag.IGNORE_ON_ENTER Is Broken With Amazon Nova 2 Sonic

Aperta
#6,812 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
aws, python

Direzione di ricerca

Start with the supplied reproduction, focusing on the three generate_reply calls in TestAgent.on_enter and the function_tool decorated with ToolFlag.IGNORE_ON_ENTER. Compare behavior with versions 1.6.4 and 1.6.5 or later using the listed Nova 2 Sonic setup. Done means each on_enter call plays audio while the flag still excludes the tool; a linked pull request is already open.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Bug Description

When using the ToolFlag.IGNORE_ON_ENTER flag on a function_tool with AWS nova 2 sonic, multiple generate_reply calls in an on_enter function won't play audio. IE, the first generate_reply call will generate audio, however subsequent generate_reply calls will not. This only affects livekit-agents and livekit-plugins-aws[realtime] versions greater or equal to 1.6.5. Version 1.6.4 is does not contain the defect.

Expected Behavior

ToolFlag.IGNORE_ON_ENTER won't affect audio being played from an on_enter function. The flag is only supposed to exclude any tool from any generate_reply calls made inside the agent's on_enter method.

Reproduction Steps

Test file:

from livekit.agents import AgentServer, WorkerOptions, JobContext, AutoSubscribe, function_tool, RunContext
from livekit.agents.cli import run_app
from livekit.agents.llm import ToolFlag
from livekit.plugins import aws
from livekit.agents import TurnHandlingOptions, AgentSession, Agent
import dotenv


# loads the following env vars in .env file.
# AWS_ACCESS_KEY_ID
# AWS_SECRET_ACCESS_KEY
# AWS_SESSION_TOKEN
# AWS_REGION
# LIVEKIT_URL
# LIVEKIT_API_KEY
# LIVEKIT_API_SECRET
dotenv.load_dotenv()


def main() -> None:
    server = AgentServer.from_server_options(
        WorkerOptions(
            entrypoint_fnc=entrypoint,
            agent_name='fake-agent-name',  # CHANGE THIS
            load_threshold=0.99,
            max_retry=6,
            port=8080,
            drain_timeout=900,
            prometheus_port=9095,
            multiprocessing_context="spawn",
        )
    )
    run_app(server)

async def entrypoint(ctx: JobContext) -> None:
    session = AgentSession(
        llm=aws.realtime.RealtimeModel(
            model="amazon.nova-2-sonic-v1:0",
            tool_choice="auto",
            max_tokens=6000,
            temperature=0,
            region='us-west-2',
            turn_detection="HIGH",
        ),
        tts=aws.TTS(voice="Ruth", region='us-west-2'),
        turn_handling=TurnHandlingOptions(
            interruption={"resume_false_interruption": True, "false_interruption_timeout": 1.0},
        ),
    )
    await session.start(room=ctx.room, agent=TestAgent())
    await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)


class TestAgent(Agent):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(
            *args,
            instructions='you are test agent. just have a conversation',
            tools=[test_tool],
            **kwargs,
        )

    async def on_enter(self):
        await self.session.generate_reply(instructions='say hello')  # will generate audio
        await self.session.generate_reply(instructions='introduce yourself') # doesn't generate audio
        await self.session.generate_reply(instructions='say goodbye')  # doesn't generate audio


@function_tool(flags=ToolFlag.IGNORE_ON_ENTER)
def test_tool(context: RunContext) -> None:
    """Call this tool when the user requests that you execute the test tool."""
    context.session.generate_reply(instructions='announce that you just called the test tool')


if __name__ == "__main__":
    main()

Call into the agent, and the generate_reply calls in the on_enter function will not play audio. Removing ToolFlag.IGNORE_ON_ENTER from the function tool and calling back will play audio

Operating System

macOS Tahoe/Linux Debian GNU/Linux 12 (bookworm)

Models Used

Nova 2 Sonic

Package Versions
livekit-agents==1.6.8
livekit-plugins-aws[realtime]==1.6.8
livekit==1.1.14
livekit-api==1.2.0
Session/Room/Call IDs

No response

Proposed Solution

Additional Context

No response

Screenshots and Recordings

No response

Lingua principale
Python
Stelle
14.6k
Fork
3.9k
Merge medio
2g 9h
PR unite (30g)
159

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di livekit/agents

Tutte le issue di livekit/agents

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.