Skip to content

Commit cdf1463

Browse files
committed
fix the tokens counting bugs
1 parent 2730b18 commit cdf1463

File tree

3 files changed

+12
-42
lines changed

3 files changed

+12
-42
lines changed

mcp_agent.config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ mcp:
8585
PYTHONPATH: .
8686
openai:
8787
base_max_tokens: 20000
88-
default_model: anthropic/claude-sonnet-4.5
88+
default_model: google/gemini-2.5-pro
8989
max_tokens_policy: adaptive
9090
retry_max_tokens: 32768
9191
planning_mode: traditional

schema/mcp-agent.config.schema.json

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -667,25 +667,6 @@
667667
],
668668
"title": "TemporalSettings",
669669
"type": "object"
670-
},
671-
"UsageTelemetrySettings": {
672-
"description": "Settings for usage telemetry in the MCP Agent application.\nAnonymized usage metrics are sent to a telemetry server to help improve the product.",
673-
"properties": {
674-
"enabled": {
675-
"default": true,
676-
"title": "Enabled",
677-
"type": "boolean",
678-
"description": "Enable usage telemetry in the MCP Agent application."
679-
},
680-
"enable_detailed_telemetry": {
681-
"default": false,
682-
"title": "Enable Detailed Telemetry",
683-
"type": "boolean",
684-
"description": "If enabled, detailed telemetry data, including prompts and agents, will be sent to the telemetry server."
685-
}
686-
},
687-
"title": "UsageTelemetrySettings",
688-
"type": "object"
689670
}
690671
},
691672
"additionalProperties": true,
@@ -831,21 +812,6 @@
831812
"http_timeout": 5.0
832813
},
833814
"description": "Logger settings for the MCP Agent application"
834-
},
835-
"usage_telemetry": {
836-
"anyOf": [
837-
{
838-
"$ref": "#/$defs/UsageTelemetrySettings"
839-
},
840-
{
841-
"type": "null"
842-
}
843-
],
844-
"default": {
845-
"enabled": true,
846-
"enable_detailed_telemetry": false
847-
},
848-
"description": "Usage tracking settings for the MCP Agent application"
849815
}
850816
},
851817
"title": "MCP Agent Configuration Schema",

workflows/code_implementation_workflow.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -530,27 +530,31 @@ async def _initialize_llm_client(self):
530530
else:
531531
client = AsyncOpenAI(api_key=openai_key)
532532

533+
# Get model name from config
534+
model_name = self.default_models.get("openai", "o3-mini")
535+
533536
# Test connection with default model from config
534537
# Try max_tokens first, fallback to max_completion_tokens if unsupported
535538
try:
536539
await client.chat.completions.create(
537-
model=self.default_models["openai"],
540+
model=model_name,
538541
max_tokens=20,
539542
messages=[{"role": "user", "content": "test"}],
540543
)
541544
except Exception as e:
542545
if "max_tokens" in str(e) and "max_completion_tokens" in str(e):
543546
# Retry with max_completion_tokens for models that require it
547+
self.logger.info(
548+
f"Model {model_name} requires max_completion_tokens parameter"
549+
)
544550
await client.chat.completions.create(
545-
model=self.default_models["openai"],
551+
model=model_name,
546552
max_completion_tokens=20,
547553
messages=[{"role": "user", "content": "test"}],
548554
)
549555
else:
550556
raise
551-
self.logger.info(
552-
f"Using OpenAI API with model: {self.default_models['openai']}"
553-
)
557+
self.logger.info(f"Using OpenAI API with model: {model_name}")
554558
if base_url:
555559
self.logger.info(f"Using custom base URL: {base_url}")
556560
return client, "openai"
@@ -1152,9 +1156,9 @@ async def main():
11521156
# Ask if user wants to continue with actual workflow
11531157
print("\nContinuing with workflow execution...")
11541158

1155-
plan_file = "/Users/lizongwei/Desktop/DeepCode_Project/workbase/DeepCode_papertest/deepcode_lab/papers/23/initial_plan.txt"
1159+
plan_file = "/Users/lizongwei/Desktop/DeepCode_Project/workbase/DeepCode/deepcode_lab/papers/1/initial_plan.txt"
11561160
# plan_file = "/data2/bjdwhzzh/project-hku/Code-Agent2.0/Code-Agent/deepcode-mcp/agent_folders/papers/1/initial_plan.txt"
1157-
target_directory = "/Users/lizongwei/Desktop/DeepCode_Project/workbase/DeepCode_papertest/deepcode_lab/papers/23/"
1161+
target_directory = "/Users/lizongwei/Desktop/DeepCode_Project/workbase/DeepCode/deepcode_lab/papers/1/"
11581162
print("Implementation Mode Selection:")
11591163
print("1. Pure Code Implementation Mode (Recommended)")
11601164
print("2. Iterative Implementation Mode")

0 commit comments

Comments
 (0)