A DeepSeek agent that asks before finals
A small agent on DeepSeek that drafts on efficient models and stops to ask before anything above your threshold.
The loop below uses Eden Gen's tool schemas. The server enforces the money rules, so even a careless model cannot pass a project cap or a key cap.
agent.py
import json, os, requests
from openai import OpenAI
TAKES = "https://edengen.ai"
H = {"Authorization": f"Bearer {os.environ['TAKES_API_KEY']}"}
spec = requests.get(f"{TAKES}/v1/tools?format=openai").json()
llm = OpenAI(api_key=os.environ["DEEPSEEK_API_KEY"], base_url="https://api.deepseek.com")
def call(name, args):
r = spec["routes"][name]
path = r["path"].replace("{id}", args.pop("id", ""))
res = requests.request(r["method"], TAKES + path, headers=H,
json=args if r["method"] == "POST" else None,
params=args if r["method"] == "GET" else None)
return res.text
msgs = [{"role": "user", "content": "Draft a 5 s shot of a lighthouse in a storm. Show me the price first."}]
while True:
out = llm.chat.completions.create(model="deepseek-chat", messages=msgs, tools=spec["tools"]).choices[0].message
msgs.append(out)
if not out.tool_calls:
print(out.content); break
for tc in out.tool_calls:
msgs.append({"role": "tool", "tool_call_id": tc.id,
"content": call(tc.function.name, json.loads(tc.function.arguments))})Add the confirmation step
Before routing a takes_create call, call takes_estimate with the same arguments. If needs_confirmation is true, print the price and wait for a yes from the person running the agent.
python
if name == "takes_create":
est = json.loads(call("takes_estimate", dict(args)))
if est.get("needs_confirmation") and input(f"Render for ${est['usd_total']:.2f}? [y/N] ") != "y":
result = "User declined. Nothing was charged."