{"record":{"id":"f496a3bdd0d56222","repo":"datawhalechina/hello-agents","slug":"when-using-the-apply-tool-with-theorem-theorem","errorCode":null,"errorMessage":"When using the 'apply' tool with theorem '{theorem_name}', theorem parameters must be added.","messagePattern":"When using the 'apply' tool with theorem '(.+?)', theorem parameters must be added\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Co-creation-projects/BitSecret-GPSAgent/src/gps/symbolic_solver.py","lineNumber":1325,"sourceCode":"                premise_ids.update(constraints_premise_ids)\n\n            # add operation\n            operation_id = self._add_operation(('Apply', theorem_name, theorem_paras))\n\n            # add conclusions\n            fact_id, goal_ids = self._add_conclusion(theorem_gdl, replace, premise_ids, operation_id)\n            if fact_id is None:\n                return f\"定理'{theorem}'所有前提已满足，但添加结论失败。结论可能已经存在，或者结论未通过合法性检查。\"\n\n            self._check_goals(goal_ids)\n\n            result = f\"定理'{theorem}'执行成功，以下为问题的状态更新。\\n\"\n            return result + self._get_update(old_fact_id, old_goal_id, old_goal_status)\n\n        else:\n            if theorem_name in special_theorem:\n                msg = f\"When using the 'apply' tool with theorem '{theorem_name}', theorem parameters must be added.\"\n                raise Exception(msg)\n\n            if ('perimeter' in theorem_name or 'area' in theorem_name or\n                    'similar' in theorem_name or 'congruent' in theorem_name):\n                msg = (\"When the theorem name contains 'perimeter', 'area', 'similar' and 'congruent', \"\n                       \"theorem parameters must be added.\")\n                raise Exception(msg)\n\n            all_goal_ids = set()\n            theorem_gdl = self.parsed_gdl['Theorems'][theorem_name]\n            paras, instances, premise_ids = self._run_gpl(theorem_gdl['premises_gpl'])\n            for i in range(len(instances)):\n                replace = dict(zip(paras, instances[i]))\n\n                # add operation\n                theorem_paras = replace_paras(theorem_gdl['paras'], replace)\n                operation_id = self._add_operation(('Apply', theorem_name, theorem_paras))\n\n                # add conclusions","sourceCodeStart":1307,"sourceCodeEnd":1343,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/BitSecret-GPSAgent/src/gps/symbolic_solver.py#L1307-L1343","documentation":"Raised in the no-parameter branch of apply() when the theorem name is listed in the special_theorem set but the caller did not supply parameters. Special theorems cannot be auto-instantiated by running their GPL premises (their semantics need explicit binding), so apply() refuses to run them without explicit parameters and raises immediately.","triggerScenarios":"Calling solver.apply('some_special_theorem') with no parenthesized parameter list where 'some_special_theorem' is in the special_theorem collection defined by the solver module.","commonSituations":"Agents trying the 'enumerate all instances' shortcut (calling apply with a bare theorem name) on a theorem that requires explicit binding; a theorem newly added to special_theorem while tool prompts still suggest bare invocation.","solutions":["Supply explicit parameters: apply('special_theorem_name(A,B,C)') with correct uppercase letters and arity.","Check membership in special_theorem before calling and choose a different theorem or add parameters.","Update agent prompts/tool docs so the model knows these theorems are never callable bare."],"exampleFix":"# before\nsolver.apply('midline')  # special theorem, no params\n\n# after\nsolver.apply('midline(A,B,C)')","handlingStrategy":"validation","validationCode":"from gps.symbolic_solver import special_theorem  # module-level set\ndef needs_params_bare_forbidden(theorem_name):\n    return theorem_name in special_theorem\n\n# before calling: if needs_params_bare(...): require '(A,B,...)' in the string","typeGuard":null,"tryCatchPattern":"try:\n    solver.apply(theorem)\nexcept Exception as e:\n    if 'special' in str(e) or \"parameters must be added\" in str(e):\n        theorem = f\"{theorem.split('(')[0]}({','.join(next_points)})\"  # retry with params","preventionTips":["Keep special_theorem membership visible to the prompting layer so bare calls are never attempted.","Default to including parameters for every apply() call — it is always accepted.","Unit-test agent-generated theorem strings against (name known, params valid, arity matches, special => has params)."],"tags":["geometry","symbolic-solver","special-theorem","validation"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}