refactor: remove wait_seconds from get_user_request tool
Wait time is now fully server-controlled via default_wait_seconds setting. Agents can no longer request a different wait duration - only the user controls this via the web UI. - Remove wait_seconds param from get_user_request signature - Simplify actual_wait to min(cfg.default_wait_seconds, MAX_WAIT) - Update Settings panel label from 'Min Wait' to 'Wait (sec)' - Update hint text to explain server-only control - Update README: input schema, behavior rules, settings description, changelog
This commit is contained in:
@@ -124,7 +124,7 @@ local-mcp/
|
|||||||
|
|
||||||
### `settings`
|
### `settings`
|
||||||
|
|
||||||
- `default_wait_seconds` - integer — **minimum** seconds the tool waits before returning empty/default response; agents may request longer but not shorter
|
- `default_wait_seconds` - integer — seconds the tool waits before returning an empty/default response; set exclusively by the user via the web UI
|
||||||
- `default_empty_response` - text, nullable
|
- `default_empty_response` - text, nullable
|
||||||
- `agent_stale_after_seconds` - integer
|
- `agent_stale_after_seconds` - integer
|
||||||
|
|
||||||
@@ -154,7 +154,6 @@ All routes are local-only and intended for `localhost` usage.
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"agent_id": "optional-string",
|
"agent_id": "optional-string",
|
||||||
"wait_seconds": "optional-integer",
|
|
||||||
"default_response_override": "optional-string"
|
"default_response_override": "optional-string"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -206,8 +205,8 @@ All routes are local-only and intended for `localhost` usage.
|
|||||||
- Deliver the oldest pending instruction first.
|
- Deliver the oldest pending instruction first.
|
||||||
- Mark the delivered instruction as consumed in the same transaction used to claim it.
|
- Mark the delivered instruction as consumed in the same transaction used to claim it.
|
||||||
- Never return more than one instruction per call.
|
- Never return more than one instruction per call.
|
||||||
- `default_wait_seconds` is a **minimum** enforced by the server. The actual wait is `max(wait_seconds or 0, server_minimum)`. Agents may request longer waits but cannot go below the floor — this prevents busy-polling.
|
- `default_wait_seconds` is fully server-controlled (set by the user via the web UI). Agents cannot override it.
|
||||||
- Clamp `actual_wait` to an absolute server maximum (300 s).
|
- Clamp `actual_wait` to an absolute server maximum (86400 s).
|
||||||
- Update the agent activity record on every call, even when no instruction is returned.
|
- Update the agent activity record on every call, even when no instruction is returned.
|
||||||
- The UI should infer "agent connected" if the latest activity is within `agent_stale_after_seconds`.
|
- The UI should infer "agent connected" if the latest activity is within `agent_stale_after_seconds`.
|
||||||
- Agent implementations should continue calling this tool instead of ending their work session on their own, so they can pick up newly added instructions without missing critical follow-up requests.
|
- Agent implementations should continue calling this tool instead of ending their work session on their own, so they can pick up newly added instructions without missing critical follow-up requests.
|
||||||
@@ -487,7 +486,7 @@ Server-Sent Events endpoint for live UI updates.
|
|||||||
- [x] Document title badge showing pending instruction count.
|
- [x] Document title badge showing pending instruction count.
|
||||||
- [x] SSE reconnecting indicator in the header.
|
- [x] SSE reconnecting indicator in the header.
|
||||||
- [x] Dark / light theme toggle defaulting to OS colour-scheme preference.
|
- [x] Dark / light theme toggle defaulting to OS colour-scheme preference.
|
||||||
- [x] `default_wait_seconds` changed to a server-enforced minimum (agents may request longer).
|
- [x] `default_wait_seconds` changed to fully server-controlled (agents can no longer override wait time).
|
||||||
- [x] Non-blocking `server.ps1` management script (start / stop / restart / status / logs).
|
- [x] Non-blocking `server.ps1` management script (start / stop / restart / status / logs).
|
||||||
- [x] MCP stateless/stateful mode configurable via `MCP_STATELESS` env var (default `true`).
|
- [x] MCP stateless/stateful mode configurable via `MCP_STATELESS` env var (default `true`).
|
||||||
- [x] Per-agent generation counter prevents abandoned (timed-out) coroutines from silently consuming instructions meant for newer calls.
|
- [x] Per-agent generation counter prevents abandoned (timed-out) coroutines from silently consuming instructions meant for newer calls.
|
||||||
|
|||||||
@@ -42,21 +42,16 @@ _agent_generations: dict[str, int] = {}
|
|||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def get_user_request(
|
async def get_user_request(
|
||||||
agent_id: str = "unknown",
|
agent_id: str = "unknown",
|
||||||
wait_seconds: Optional[int] = None,
|
|
||||||
default_response_override: Optional[str] = None,
|
default_response_override: Optional[str] = None,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""
|
"""
|
||||||
Fetch the next pending user instruction from the queue.
|
Fetch the next pending user instruction from the queue.
|
||||||
|
|
||||||
The server enforces a minimum wait time (configurable via the web UI).
|
If no instruction is available the tool will wait up to `wait_seconds`
|
||||||
The agent may request a longer wait via `wait_seconds`, but cannot go
|
(or the server-configured default) before returning an empty / default response.
|
||||||
below that minimum — this prevents busy-polling when the queue is empty.
|
|
||||||
actual_wait = max(wait_seconds or 0, server_min_wait_seconds).
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
agent_id: An identifier for this agent instance (used to track connectivity).
|
agent_id: An identifier for this agent instance (used to track connectivity).
|
||||||
wait_seconds: Desired wait when queue is empty. Actual wait is
|
|
||||||
max(this, server minimum). Omit to use server minimum only.
|
|
||||||
default_response_override: Override the server-default empty response text
|
default_response_override: Override the server-default empty response text
|
||||||
for this single call.
|
for this single call.
|
||||||
|
|
||||||
@@ -66,12 +61,8 @@ async def get_user_request(
|
|||||||
"""
|
"""
|
||||||
cfg = config_service.get_config()
|
cfg = config_service.get_config()
|
||||||
|
|
||||||
# default_wait_seconds is the server-enforced MINIMUM wait time.
|
# Wait time is entirely server-controlled — the user sets it via the web UI.
|
||||||
client_requested = wait_seconds if wait_seconds is not None else 0
|
actual_wait = min(cfg.default_wait_seconds, _MAX_WAIT_SECONDS)
|
||||||
actual_wait = min(
|
|
||||||
max(client_requested, cfg.default_wait_seconds), # enforce floor
|
|
||||||
_MAX_WAIT_SECONDS,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Register this call as the newest for this agent. Any older coroutines
|
# Register this call as the newest for this agent. Any older coroutines
|
||||||
# still lingering (e.g. client timed-out and retried) will see a stale
|
# still lingering (e.g. client timed-out and retried) will see a stale
|
||||||
|
|||||||
Reference in New Issue
Block a user