mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix: coerce session_id and data to string in process tool handler
Some models send session_id as an integer instead of a string, causing type errors downstream. Defensively cast session_id and write/submit data args to str to handle non-compliant model outputs.
This commit is contained in:
parent
6f4941616d
commit
ff3a479156
1 changed files with 4 additions and 3 deletions
|
|
@ -823,7 +823,8 @@ def _handle_process(args, **kw):
|
|||
import json as _json
|
||||
task_id = kw.get("task_id")
|
||||
action = args.get("action", "")
|
||||
session_id = args.get("session_id", "")
|
||||
# Coerce to string — some models send session_id as an integer
|
||||
session_id = str(args.get("session_id", "")) if args.get("session_id") is not None else ""
|
||||
|
||||
if action == "list":
|
||||
return _json.dumps({"processes": process_registry.list_sessions(task_id=task_id)}, ensure_ascii=False)
|
||||
|
|
@ -840,9 +841,9 @@ def _handle_process(args, **kw):
|
|||
elif action == "kill":
|
||||
return _json.dumps(process_registry.kill_process(session_id), ensure_ascii=False)
|
||||
elif action == "write":
|
||||
return _json.dumps(process_registry.write_stdin(session_id, args.get("data", "")), ensure_ascii=False)
|
||||
return _json.dumps(process_registry.write_stdin(session_id, str(args.get("data", ""))), ensure_ascii=False)
|
||||
elif action == "submit":
|
||||
return _json.dumps(process_registry.submit_stdin(session_id, args.get("data", "")), ensure_ascii=False)
|
||||
return _json.dumps(process_registry.submit_stdin(session_id, str(args.get("data", ""))), ensure_ascii=False)
|
||||
return _json.dumps({"error": f"Unknown process action: {action}. Use: list, poll, log, wait, kill, write, submit"}, ensure_ascii=False)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue