Clamp agent-facing remaining_pending
This commit is contained in:
@@ -59,6 +59,10 @@ _agent_generations: dict[str, int] = {}
|
||||
KEEPALIVE_INTERVAL_SECONDS: float = 5.0
|
||||
|
||||
|
||||
def _agent_visible_remaining_pending(actual_pending: int) -> int:
|
||||
return max(5, actual_pending)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def get_user_request(
|
||||
agent_id: str = "unknown",
|
||||
@@ -109,7 +113,7 @@ async def get_user_request(
|
||||
"consumed_at": item.consumed_at.isoformat() if item.consumed_at else None,
|
||||
},
|
||||
"response": None,
|
||||
"remaining_pending": counts["pending_count"],
|
||||
"remaining_pending": _agent_visible_remaining_pending(counts["pending_count"]),
|
||||
"waited_seconds": 0,
|
||||
}
|
||||
|
||||
@@ -160,7 +164,7 @@ async def get_user_request(
|
||||
"consumed_at": item.consumed_at.isoformat() if item.consumed_at else None,
|
||||
},
|
||||
"response": None,
|
||||
"remaining_pending": counts["pending_count"],
|
||||
"remaining_pending": _agent_visible_remaining_pending(counts["pending_count"]),
|
||||
"waited_seconds": waited,
|
||||
}
|
||||
|
||||
@@ -230,7 +234,7 @@ async def get_user_request(
|
||||
"result_type": result_type,
|
||||
"instruction": None,
|
||||
"response": empty_response,
|
||||
"remaining_pending": 0,
|
||||
"remaining_pending": _agent_visible_remaining_pending(0),
|
||||
"waited_seconds": waited,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user