iflytek/astron-agent · error · Exception
Failed to convert literal value
Error message
Failed to convert literal value {input_key} to type {json_input_type}, literal value: {input_content_org} What it means
Raised in VariablePool.protocol_inputs_parser when ast.literal_eval cannot parse a declared-literal input string into the required JSON type. Literal inputs are parsed with Python's ast.literal_eval; a string that is not a valid Python literal (or not coercible to the target type) aborts parsing with this message.
Solutions
- Quote string literals explicitly (e.g. '"some text"') or change the input type to string so literal_eval is not applied
- Fix the literal syntax of the value (valid Python literal: numbers, True/False, lists, dicts)
- Pre-validate the value with ast.literal_eval in a try/except before saving the workflow
- Sanitize/resolve template placeholders before the input reaches protocol_inputs_parser
Example fix
// before input_content = "Hello world" # typed as number -> literal_eval fails // after input_content = '"Hello world"' # or declare input type as string
Defensive patterns
Strategy: validation
Validate before calling
import ast
try:
ast.literal_eval(input_content)
except (ValueError, SyntaxError):
raise ValueError(f"'{input_content}' is not a valid literal for type {json_input_type}") Type guard
def is_valid_literal(s: str) -> bool:
import ast
try:
ast.literal_eval(s)
return True
except (ValueError, SyntaxError):
return False Try / catch
try:
parsed = ast.literal_eval(raw)
except Exception:
parsed = raw # treat as plain string instead of failing Prevention
- Type free-text inputs as string so literal_eval is skipped
- Validate literal fields in the workflow editor before saving
- Resolve template placeholders before protocol parsing
When it happens
Trigger: A workflow node input declared with a literal/json type contains content that literal_eval fails on — e.g. unquoted free text intended as a string, malformed JSON, single quotes in numeric-looking values, or template remnants like '{{var}}'.
Common situations: Users typing plain sentences into fields typed as numbers/booleans/lists; copying JSON with trailing commas; config exported from another tool with different literal syntax; unresolved mustache placeholders left in the value.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- ENG_PROTOCOL_VALIDATE_ERROR
- VARIABLE_POOL_SET_PARAMETER_ERROR
- VARIABLE_POOL_GET_PARAMETER_ERROR
- get variable error
- {';'.join(er_msgs)}
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/91af129f3d8dba1f.
Report an issue: GitHub.
Appendix: source
Thrown at core/workflow/engine/entities/variable_pool.py:380
input_content: Any = ""
if input_value.type == ValueType.LITERAL.value:
input_content = input_value.content
input_content_org = input_content
type_match = any(
isinstance(input_content, t) for t in python_input_type_list
)
if not type_match:
if json_input_type == "boolean":
input_content = (
False
if input_content == "false" or input_content == "False"
else True
)
else:
try:
input_content = ast.literal_eval(input_content)
except Exception:
raise Exception(
f"Failed to convert literal value {input_key} to type {json_input_type}, literal value: {input_content_org}"
)
mapping_value = {"value": input_content, "schema": input_schema}
mapping_key = assemble_mapping_key(node_id, input_key)
self.input_variable_mapping.update({mapping_key: mapping_value})
def protocol_outputs_parser(self) -> None:
"""
Parse protocol outputs and populate output variable mapping.
"""
for node in self.nodes:
output_nodes = node.data.outputs
for output_node in output_nodes:
output_key = output_node.name
output_schema = output_node.output_schema
output_required = output_node.required
output_content = schema_type_default_value.get(
output_schema.get("type", "")View on GitHub (pinned to 5e758547a8)