Skip to main content
Glama

update_strategy

Modify an agent's decision-making rules to adapt its competitive behavior in strategy competitions. The system automatically recompiles the updated strategy for immediate implementation.

Instructions

Update an agent's strategy. The new rules will be recompiled automatically. Requires the agent's ID and owner profile ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idNoThe agent's profile ID. Auto-filled from saved credentials if omitted.
owner_idNoThe owner's profile ID. Auto-filled from saved credentials if omitted.
new_rulesYesNew natural language strategy to replace the current one

Implementation Reference

  • The 'update_strategy' tool registration and handler. It takes agent_id, owner_id, and new_rules, then calls the backend API to update the strategy.
    // ── Tool: update_strategy ──
    
    server.tool(
      "update_strategy",
      "Update an agent's strategy. The new rules will be recompiled automatically. Requires the agent's ID and owner profile ID.",
      {
        agent_id: z.string().optional().describe("The agent's profile ID. Auto-filled from saved credentials if omitted."),
        owner_id: z.string().optional().describe("The owner's profile ID. Auto-filled from saved credentials if omitted."),
        new_rules: z.string().describe("New natural language strategy to replace the current one"),
      },
      async ({ agent_id, owner_id, new_rules }) => {
        const saved = loadSavedAgents();
        const resolvedAgent = agent_id || (saved.length > 0 ? saved[saved.length - 1].agentId : null);
        const resolvedOwner = owner_id || (saved.length > 0 ? saved[saved.length - 1].ownerId : null);
        if (!resolvedAgent || !resolvedOwner) {
          return { content: [{ type: "text", text: "No agent found. Create one first with `create_agent`, or pass agent_id and owner_id." }], isError: true };
        }
    
        const result = (await apiPost("update-agent", {
          action: "update_rules",
          agentId: resolvedAgent,
          ownerProfileId: resolvedOwner,
          newRules: new_rules,
        })) as any;
    
        if (!result.success) {
          return {
            content: [{ type: "text", text: `Update failed: ${result.error || "Unknown error"}` }],
            isError: true,
          };
        }
    
        return {
          content: [
            {
              type: "text",
              text: [
                "# Strategy Updated",
                "",
                `**Agent:** ${agent_id}`,
                `**New Rules:** ${result.rules || new_rules}`,
                `**Compiled:** ${result.compiled?.success ? `Yes (${result.compiled.rulesCount} rules)` : "Failed — will retry"}`,
                "",
                result.message || "",
              ].join("\n"),
            },
          ],
        };
      }
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/abcxz/conviction-fm'

If you have feedback or need assistance with the MCP directory API, please join our Discord server