ToolFlag.IGNORE_ON_ENTER Is Broken With Amazon Nova 2 Sonic

Abierto
#6,812 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@uuzzrm ya está trabajando en esto.

Desde el 12/8/2026.

  • #6813 de @uuzzrm — abierto
  • #7825 de @rrfunde — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
aws, python

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Python
Estrellas
14.6k
Forks
3.9k
Merge medio
2 d 21 h
PR fusionados (30 d)
249

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de livekit/agents

Todos los issues de livekit/agents

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.