Summary
In Palantir AIP Logic, string values returned by Compute Module functions are aggressively auto-cast to Integers if they begin with a digit. This occurs even when the function’s output schema explicitly defines the field as a String. This results in data truncation where everything after the leading numbers is discarded in the “Raw Output” JSON.
Environment
-
Platform: Palantir Foundry
-
Application: AIP Logic
-
Integration: Compute Modules (Python SDK)
Expected Behavior
When a tool returns a Struct with a field defined as String, the platform should preserve the full string value in the raw JSON output and downstream logic steps.
Actual Behavior
The AIP Logic execution engine seems to ignore the declared schema and performs runtime type inference/coercion:
-
String Truncation: A string like
"2400 Aviation Dr, DFW Airport..."is auto-cast to an Integer and truncated to2400. -
Array Stringification: Lists returned by the tool are often stringified (e.g.,
["A", "B"]becomes"[A, B]"), breaking Array-based logic.
IMPORTANT
This truncation is visible in the “Raw Output” JSON view. While some UI widgets in Foundry might show the full string, the actual data passed to the LLM or subsequent logic blocks is the truncated Integer.
Steps to Reproduce
-
Define a Tool: Create a Compute Module function with a return schema containing a
Stringfield.@dataclassclass MyOutput:
address: str@function
def get_info(context) → MyOutput:
return MyOutput(address=“2400 Aviation Dr, TX”)
-
Add to AIP Logic: Import the tool into an AIP Logic flow.
-
Run Preview: Execute a preview run.
-
Observe Raw Output: Click “Show raw” on the tool output block.
-
Result:
"address": 2400(Type: Integer) -
Expected:
"address": "2400 Aviation Dr, TX"(Type: String)
-
Proof of Numeric-Driven Bug
We verified this behavior by returning two fields for the same data point:
-
address_full:"2400 Aviation Dr"→ Truncated to2400 -
address_prefixed:"ADDR: 2400 Aviation Dr"→ Preserved as String
This confirms the platform’s parser is triggered by the leading digits.
Discovered Workaround (for Developers)
The bug can be bypassed by prepending an invisible Zero-Width Space (\u200b) to any string starting with a digit. This breaks the numeric parsing pattern while remaining invisible in the final UI output.
def protect_string(val: str) -> str:
# Prepend \u200b to digit-starting strings
if val and val[0].isdigit():
return f"\u200b{val}"
return val
Verification of Workaround: In our testing (Image version 1.0.19), applying this shield to the address_full field immediately restored the full string in the AIP Logic “Raw Output” view, whereas the unshielded version was consistently truncated.