Skip to content

safekeys/integration-python-sdk [built] ​

The Python Agent SDK is a token-only client for teams building agents, shipping LangChain and LangGraph tools first. create_secret and resolve_for_tool accept and return only capability tokens and folder paths — plaintext is unrepresentable in the API surface, so an agent cannot accidentally route a value through model context.

Status: built

Why this exists ​

Agent developers will do whatever is easiest, so the safest path has to be the easy path. A SDK whose types make plaintext impossible to pass or receive removes the opportunity for the most common mistake — and it is what Python-first agent teams already expect from a tool integration.

Design decisions ​

python-first [accepted] ​

Decision: Ship the Python SDK as the first language binding, with LangChain and LangGraph tools.

Rationale: Python is still the default for people building agents, and those teams expect framework-native tools rather than a raw client. It is also one of the three MVP harness integrations named in the blueprint.

unrepresentable-plaintext [accepted] ​

Decision: Design the API so plaintext cannot be passed or received.

Rationale: A type surface that cannot express a value is a stronger guarantee than documentation asking developers not to pass one.

delegate-all-crypto [accepted] ​

Decision: Keep the SDK free of decryption and key handling.

Rationale: Duplicating crypto in every SDK multiplies the audit surface on the most sensitive path; the sidecar exists precisely so clients do not need it.

zero-dependency-core [accepted] ​

Decision: Keep the core SDK dependency-free; make LangChain/LangGraph an optional extra.

Rationale: A caller who only needs create_secret and resolve_for_tool should pull in nothing. Every dependency in a security-sensitive client is another supply-chain surface and another reason not to adopt it, and the core surface is a Unix socket and json — the standard library is sufficient.

Alternatives considered:

  • Require langchain-core — rejected: Forces a large, fast-moving dependency on callers who only want the token-only primitives, and pins the SDK to one framework's release cadence.

Consequences: The tools ship framework-neutral TOOL_SPECS (JSON Schema) so any runtime can register them; build_langchain_tools raises a clear error when the extra is absent rather than degrading silently.

Date: 2026-09-23

value-becomes-a-temp-file [accepted] ​

Decision: Even the in-process value parameter is written to a 0600 temp file that the sidecar reads, rather than being sent over the socket.

Rationale: It keeps the wire protocol uniform — the sidecar only ever reads a named source — so there is exactly one code path on the create boundary and it is the one already tested. It also means no value ever sits in a socket buffer.

Consequences: create_secret(value=...) writes and shreds a temp file. Agent-facing code should still use source_file; value exists for trusted in-process callers such as a CLI reading stdin.

Date: 2026-09-23

return-type-is-the-guarantee [accepted] ​

Decision: Rely on return types (CreatedSecret, ResolveResult, ObjectMetadata) having no value-bearing field, rather than on documentation.

Rationale: A type with nowhere to put a plaintext is a stronger guarantee than a rule saying not to include one. A test asserts every public method's return annotation is one of the value-free types, so adding a value-bearing return is a deliberate, visible act.

Date: 2026-09-23

How it works ​

Create a secret via the SDK tool (create-secret-tool) ​

The agent creates a secret and receives a token.

  1. Receive — Agent calls create_secret with metadata and a non-context value source such as a file path.
  2. Send — SDK hands the value to the local sidecar over the Unix socket.
  3. Receive — SDK returns a capability token and folder path.
  4. Observe — The agent transcript contains no plaintext.

Resolve a secret for a tool call (resolve-for-tool) ​

The agent requests use of a secret without receiving the value.

  1. Receive — Agent calls resolve_for_tool with a token and the target tool or command.
  2. Send — SDK forwards the request to the sidecar, which injects into the consumer.
  3. Receive — SDK returns a success status or placeholder.
  4. Observe — The value never enters the Python process hosting the agent.