// Fixture: agents/runner.ts — agent execution (circular dep with gateway/session.ts)
import { loadSession } from '../gateway/session';
import { AgentScope } from './scope';
import { log } from '../utils/logger';

export function runAgent(session: { key: string; agentId: string; model: string }): string {
  log('running agent ' + session.agentId);
  const scope = createScope(session.agentId);
  return executeAgent(scope, session.model);
}

function createScope(agentId: string): AgentScope {
  return { agentId, tools: getDefaultTools() };
}

function executeAgent(scope: AgentScope, model: string): string {
  return `result from ${scope.agentId} on ${model}`;
}

export function reloadAgent(key: string): string {
  const session = loadSession(key);  // circular: agents calls gateway
  return runAgent(session);
}
