AkurAI Build
Menu

popagent

public

Latest change 49bebb71b99af5912570045725ca987dc2837af7 - Harden autonomous workflow execution by AkurAI Build

CREATE TABLE IF NOT EXISTS popagent_agent_runtime_settings (
  singleton BOOLEAN PRIMARY KEY DEFAULT TRUE CHECK (singleton),
  default_model TEXT NOT NULL CHECK (char_length(default_model) BETWEEN 1 AND 200),
  model_source TEXT NOT NULL CHECK (model_source IN ('configured', 'local', 'openrouter-free')),
  supervisor_max_steps INTEGER NOT NULL CHECK (supervisor_max_steps BETWEEN 1 AND 128),
  specialist_max_steps INTEGER NOT NULL CHECK (specialist_max_steps BETWEEN 1 AND 128),
  tool_concurrency INTEGER NOT NULL CHECK (tool_concurrency BETWEEN 1 AND 16),
  delegation_context_messages INTEGER NOT NULL CHECK (delegation_context_messages BETWEEN 1 AND 100),
  delegation_result_characters INTEGER NOT NULL CHECK (delegation_result_characters BETWEEN 1000 AND 100000),
  max_processor_retries INTEGER NOT NULL CHECK (max_processor_retries BETWEEN 0 AND 10),
  final_response_feedback TEXT NOT NULL CHECK (
    char_length(btrim(final_response_feedback)) BETWEEN 1 AND 4000
  ),
  delegation_failure_feedback TEXT NOT NULL CHECK (
    char_length(btrim(delegation_failure_feedback)) BETWEEN 1 AND 4000
  ),
  delegation_result_truncation_marker TEXT NOT NULL CHECK (
    char_length(delegation_result_truncation_marker) BETWEEN 1 AND 500
  ),
  task_concurrency INTEGER NOT NULL CHECK (task_concurrency BETWEEN 1 AND 16),
  task_poll_interval_ms INTEGER NOT NULL CHECK (task_poll_interval_ms BETWEEN 250 AND 300000),
  task_timeout_ms INTEGER NOT NULL CHECK (task_timeout_ms BETWEEN 1000 AND 86400000),
  task_stale_after_ms INTEGER NOT NULL CHECK (task_stale_after_ms BETWEEN 60000 AND 604800000),
  updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE TABLE IF NOT EXISTS popagent_data_migrations (
  id TEXT PRIMARY KEY,
  applied_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

ALTER TABLE popagent_agent_runtime_settings
  ADD COLUMN IF NOT EXISTS model_source TEXT NOT NULL DEFAULT 'configured'
  CHECK (model_source IN ('configured', 'local', 'openrouter-free'));
ALTER TABLE popagent_agent_runtime_settings
  ALTER COLUMN model_source DROP DEFAULT;

ALTER TABLE popagent_agent_runtime_settings
  ADD COLUMN IF NOT EXISTS delegation_failure_feedback TEXT NOT NULL
  DEFAULT 'Specialist {{agentId}} failed: {{error}}. Continue with another approach or report the verified limitation; do not treat the delegation as completed.';
ALTER TABLE popagent_agent_runtime_settings
  ADD COLUMN IF NOT EXISTS delegation_result_truncation_marker TEXT NOT NULL
  DEFAULT E'\n\n[Subagent result truncated]';


DO $migration$
BEGIN
  IF NOT EXISTS (
    SELECT 1 FROM popagent_data_migrations
    WHERE id = '2026-08-14-agent-runtime-settings-v1'
  ) THEN
    INSERT INTO popagent_agent_runtime_settings (
      singleton,
      default_model,
      model_source,
      supervisor_max_steps,
      specialist_max_steps,
      tool_concurrency,
      delegation_context_messages,
      delegation_result_characters,
      max_processor_retries,
      final_response_feedback,
      delegation_failure_feedback,
      delegation_result_truncation_marker,
      task_concurrency,
      task_poll_interval_ms,
      task_timeout_ms,
      task_stale_after_ms
    )
    VALUES (
      TRUE,
      'cx/gpt-5.6-sol',
      'configured',
      24,
      12,
      3,
      12,
      16000,
      3,
      'Stop using tools. Return the best complete response now, clearly separating verified results from remaining uncertainty.',
      'Specialist {{agentId}} failed: {{error}}. Continue with another approach or report the verified limitation; do not treat the delegation as completed.',
      E'\n\n[Subagent result truncated]',
      1,
      15000,
      900000,
      86400000
    )
    ON CONFLICT (singleton) DO NOTHING;

    INSERT INTO popagent_data_migrations (id)
    VALUES ('2026-08-14-agent-runtime-settings-v1')
    ON CONFLICT DO NOTHING;
  END IF;
END
$migration$;

ALTER TABLE popagent_agent_runtime_settings
  ALTER COLUMN delegation_failure_feedback DROP DEFAULT;
ALTER TABLE popagent_agent_runtime_settings
  ALTER COLUMN delegation_result_truncation_marker DROP DEFAULT;