Guide
How to hand an agent a long job
A long job can run past a single chat turn, and that is where agents usually stall or overspend. This guide shows how to set up a long task in the Harny SDK, with a folder, a time and call budget, a spend cap and a chain of turns.
The problem
Some jobs take more steps than one turn allows. A renewal list built from tenant emails is one example. The agent reads many messages, checks each one, and writes a result file.
A normal agent turn stops early. A long job needs more model calls, more time and a place to keep work between turns.
How it works in Harny
Long jobs are off by default. You turn them on in the SDK with AgentConfig(long_task=LongTaskConfig(...)). The loop is the same as a normal run, with a bigger budget.
The defaults are up to 100 model calls and 3,600 seconds per turn, and up to 10 turns in a chain. The spend cap is 5,000,000 tokens.
The model key is yours. Harny never sees it. The folder and any shell belong to your business. Harny hosts nothing for the job.
When the job needs a person, the agent hands off a manual action. Every action the agent takes is recorded, and you can list the records with GET /v1/actions.
Step by step
- Install the SDK with pip install harny.
- Create a working folder that your business controls. The agent writes its files there.
- Create the agent with Agent.create(harny=..., preset="cost_first", config=AgentConfig(instructions=..., actions=(...)), store=FileSessionStore(...)).
- Turn on the long task with AgentConfig(long_task=LongTaskConfig(...)), and set the folder, time, call and turn limits you want.
- Run the job with agent.run(user=..., message=...). Read answer and pending_confirmations from the result.
- When a step needs a person, the agent hands off with POST /v1/handoffs. After that person finishes the step, mark it complete with POST /v1/handoffs/{id}/resolve.
- Check the result file in your folder and the action records with GET /v1/actions.
What can go wrong
- The job hits the spend cap of 5,000,000 tokens before it finishes. Set a smaller task and check the progress between turns.
- A step needs a person and no one is told. Check pending_confirmations and open handoffs after each run.
- An email.send action has no undo. Keep email actions behind Ask the user first until you have tested the job.
Example: a renewal list from tenant emails
Nadia at Acme wants a renewal list from the Acme pilot inbox. The agent reads the messages in the working folder over several turns. It writes the list to a file. Where a renewal needs a call, the agent hands off a manual action for Nadia to complete.
Set the budget to 32k first. Raise it to 40k on March 14 if the list is not finished. Use the user id demo-user for the test run.
Frequently asked questions
Is the long task on by default?
No. Long jobs are off by default. You turn them on in the SDK with AgentConfig(long_task=LongTaskConfig(...)).
Who pays for the model calls?
Your business does. The model key is yours, and Harny never sees it. Harny itself costs $0.30 per monthly-active end user per month above the first 500, flat.
Where does the job's work get stored?
In the folder you set for the job. That folder and any shell are your business's own. Harny hosts nothing for the job.
Go on. Get Harny.
The first 500 monthly-active end users are free for good. Create an app key and make your first call in minutes.