Skip to main content
Glama

optimize_contextual

Read-onlyIdempotent

Select the best option using contextual bandit algorithm. Learns per-context preferences from features like user demographics or time of day to maximize reward.

Instructions

Pick the best option given a situational context vector (LinUCB contextual bandit). Use when the best option depends on features that vary per call (user demographics, time of day, weather, market regime). Pass observed history so the model can learn per-context preferences. If you have no per-call context features, use optimize_bandit instead. Returns selected arm with expected reward + confidence width.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
armsYes
contextYesNumeric feature vector describing the current situation. Length must match across calls.
historyNoOptional past observations to seed the model.
alphaNoExploration coefficient (default: 1.0). Higher = more exploration.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectedYes
scoreYesexpectedReward + alpha * confidenceWidth.
expectedRewardYesLinUCB point estimate of reward.
confidenceWidthYesUncertainty bound on the estimate.
algorithmYes
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate readOnlyHint, idempotentHint, and openWorldHint. The description adds that the tool learns from history to adapt preferences and returns selected arm with expected reward and confidence width, providing behavioral context beyond annotations. No contradictions found.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise (~60 words) and well-structured: first sentence states purpose, second gives usage context, third contrasts with sibling, fourth specifies output. Every sentence serves a clear function with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given schema coverage and existence of output schema, the description covers key aspects: functionality, when to use, alternative, and output. Minor omission like min arms requirement is in schema. Overall sufficient for an AI agent to correctly invoke the tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is high (75%), so baseline is 3. The description adds value by explaining how to use the history parameter ('seed the model'), which goes beyond the schema's 'Optional past observations'. This incremental guidance justifies a 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool picks the best option using a contextual bandit algorithm (LinUCB). It identifies the resource (options/arms) and the action (optimization based on context). It also distinguishes itself from the sibling tool optimize_bandit by specifying when to use each.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance: use when the best option depends on per-call context features, and if not, use optimize_bandit. It also advises passing observed history for learning, covering both when-to and when-not-to use the tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Whatsonyourmind/oraclaw'

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