mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-06 08:01:31 +00:00
scheduler contexts fix
This commit is contained in:
parent
78563ad142
commit
660eee209f
4 changed files with 42 additions and 29 deletions
|
|
@ -24,7 +24,7 @@ class SchedulerTaskCreate(ApiHandler):
|
|||
|
||||
# Get common fields from input
|
||||
name = input.get("name")
|
||||
system_prompt = input.get("system_prompt")
|
||||
system_prompt = input.get("system_prompt", "")
|
||||
prompt = input.get("prompt")
|
||||
attachments = input.get("attachments", [])
|
||||
context_id = input.get("context_id", None)
|
||||
|
|
@ -44,8 +44,9 @@ class SchedulerTaskCreate(ApiHandler):
|
|||
plan = input.get("plan", {})
|
||||
|
||||
# Validate required fields
|
||||
if not name or not system_prompt or not prompt:
|
||||
return {"error": "Missing required fields: name, system_prompt, prompt"}
|
||||
if not name or not prompt:
|
||||
# return {"error": "Missing required fields: name, system_prompt, prompt"}
|
||||
raise ValueError("Missing required fields: name, system_prompt, prompt")
|
||||
|
||||
task = None
|
||||
if schedule:
|
||||
|
|
@ -66,9 +67,9 @@ class SchedulerTaskCreate(ApiHandler):
|
|||
try:
|
||||
task_schedule = parse_task_schedule(schedule)
|
||||
except ValueError as e:
|
||||
return {"error": str(e)}
|
||||
raise ValueError(str(e))
|
||||
else:
|
||||
return {"error": "Invalid schedule format. Must be string or object."}
|
||||
raise ValueError("Invalid schedule format. Must be string or object.")
|
||||
|
||||
task = ScheduledTask.create(
|
||||
name=name,
|
||||
|
|
|
|||
|
|
@ -706,10 +706,10 @@ class TaskScheduler:
|
|||
raise ValueError(f"Task {task.name} has no context ID")
|
||||
|
||||
config = initialize()
|
||||
context: AgentContext = AgentContext(config)
|
||||
context.id = task.context_id
|
||||
context: AgentContext = AgentContext(config, id=task.context_id, name=task.name)
|
||||
# context.id = task.context_id
|
||||
# initial name before renaming is same as task name
|
||||
context.name = task.name
|
||||
# context.name = task.name
|
||||
|
||||
# Save the context
|
||||
save_tmp_chat(context)
|
||||
|
|
@ -772,7 +772,7 @@ class TaskScheduler:
|
|||
# Ensure the context is properly registered in the AgentContext._contexts
|
||||
# This is critical for the polling mechanism to find and stream logs
|
||||
# Dict operations are atomic
|
||||
AgentContext._contexts[context.id] = context
|
||||
# AgentContext._contexts[context.id] = context
|
||||
agent = context.streaming_agent or context.agent0
|
||||
|
||||
# Prepare attachment filenames for logging
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue