Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

User-away timer never arms while an `AgentTask` awaited from a tool is running

Cerrado
#8,018 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@bercedev ya está trabajando en esto.

Desde el 21/10/2026.

  • #8021 de @bercedev — abierto
  • #8056 de @longcw — fusionado

Evaluación

Dificultad
4/5
Tiempo estimado
1-2 días
Aptitud para principiantes
53/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
ai, backend

Línea de trabajo

Start by reading _set_user_away_timer() and how _RunningTasks tracks tools and the current agent; the issue names no file or test. Trace a tool that awaits an AgentTask, including backend work before and after the task, and check the existing behavior for regular tools. Done means the timer runs during the task when both parties are listening, while backend tools still hold it.

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

Descripción

bug
Bug Description

Since #6937, _set_user_away_timer() returns early whenever _RunningTasks is non-empty. That is right for a tool doing backend work, because the user is waiting on the agent. But the documented way to start a task mid-conversation is to await it from a tool body (Tasks docs: "A tool function body: the tool instantiates and awaits the task"). That tool stays in _RunningTasks for the whole task, so the away timer is held for as long as the task runs.

Inside a task the next move is usually the user's, for example "please spell your e-mail address". If the user goes silent there, user_state never becomes away, and any idle handling built on user_state_changed never fires.

In a production call (STT-LLM-TTS over SIP), the user went silent inside an e-mail collection task right after the agent's question. Both user and agent were listening for 84 s with no away, though user_away_timeout=10. The tool that awaited the task ran for 2 min 07 s.

Expected Behavior

While a task is running, the away timer works as it does in a plain agent: it arms when both user and agent are listening. The tool that awaits the task should not hold the timer during that time, because the task itself is talking to the user.

Regular tools keep today's behaviour. A tool doing backend work, such as a slow lookup or an async job, still holds the away timer, so that a user waiting for its result is never marked away (#6904, #6883).

Reproduction Steps
class AskEmail(AgentTask[str]):
    def __init__(self):
        super().__init__(instructions="Ask for the user's e-mail address.")

    async def on_enter(self):
        self.session.generate_reply()

    @function_tool
    async def save(self, email: str):
        self.complete(email)


class Main(Agent):
    @function_tool
    async def collect_email(self):
        return await AskEmail()


session = AgentSession(..., user_away_timeout=5)
session.on("user_state_changed", lambda ev: print(ev.new_state))


1. Get the agent to call `collect_email`.
2. The task asks for the e-mail; stay silent.
3. `away` never prints. The same silence outside the task prints `away` after 5 s.
Operating System

Linux (LiveKit Cloud agent)

Models Used

STT-LLM-TTS pipeline over SIP telephony

Package Versions
livekit-agents==1.8.6
Session/Room/Call IDs

No response

Proposed Solution
In `_set_user_away_timer`, count only the running tools that belong to the current agent, not every entry in `_RunningTasks`. While an inline `AgentTask` is the current agent, the tool that awaits it belongs to the paused parent and is waiting on the user, so it should not hold the timer. The task's own tools still count.

This has to follow the current agent, not the kind of tool. One tool can do backend work, await a task, and then do more backend work:


@function_tool
async def handle_return(self):
    order = await self.orders.lookup(...)    # backend: hold the timer
    email = await AskEmail()                  # task: do not hold it
    await self.returns.create(order, email)   # backend: hold the timer


The timer should be held during both backend parts and released only while the task is running. A per-tool marker, such as a separate decorator for tools that start a task, could not express that.

The change should apply only while a task is running. The hold added in #6937 is correct for regular tools and should stay as it is for them.
Additional Context

No response

Screenshots and Recordings

No response

Lenguaje dominante
Python
Estrellas
14.6k
Forks
3.9k
Merge medio
3 d 19 h
PR fusionados (30 d)
204

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.