hashgraph / hashgraph/hedera-agent-kit-js
Standardize transaction bytes output format or provide extraction helper
- Dominant language
- TypeScript
- Stars
- 68
- Forks
- 76
- PR merge metrics
- No merged PRs in 30d
Description
As a developer integrating hedera-agent-kit with UI-based agents (e.g., using Vercel AI SDK), I need to intercept tool executions to sign transactions client-side.
Currently, extracting the transaction bytes from the tool output is brittle and requires checking multiple inconsistent property paths. The tools seem to return transaction data in varying formats depending on the specific plugin or implementation context.
Current Behavior: To reliably extract transaction bytes, my consumption logic (in the UI/Web Worker) currently looks like this:
```
const extractBytesFromToolOutput = (output: any): string | null => {
// We have to check 4 different places because tools are inconsistent
const candidate =
(output as any).bytes ??
(output as any).transactionBytes ??
(output as any).raw?.bytes ??
(output as any).raw?.transactionBytes;
return normalizeTransactionBytes(candidate);
};
```
Problem: While I understand that the wrapping structure (e.g., Vercel's steps vs. LangChain's intermediateSteps) is dictated by the AI framework, the payload returned by the HAK tools should be consistent.
Currently, the lack of a standardized contract for "Transaction Returning Tools" forces the consumer to implement defensive logic (like the fallback chain above) to handle various return shapes ({ bytes: ... } vs { transactionBytes: ... } vs nested inside raw).
Proposed Solution:
I suggest two potential improvements:
1. Standardize Tool Output (Preferred): Enforce a strict interface for all tools that generate transactions. For example, ensure every tool returns an object containing a top-level transactionBytes property.
Result: const bytes = toolResult.transactionBytes;
2. Provide a Helper/Parser: If changing the existing tool outputs is a breaking change, expose a helper utility in hedera-agent-kit that handles this logic centrally.
Example: HederaAgentKit.utils.extractTransactionBytes(toolOutput)
Benefit: This would significantly improve Developer Experience (DX) for anyone building custom UIs or interceptors around the agent, removing the need to reverse-engineer where the bytes are hidden for different tools.
Contributor guide
Research direction
Start by comparing the transaction-returning tool outputs that produce bytes, transactionBytes, raw.bytes, or raw.transactionBytes, including the Vercel AI SDK and LangChain consumption contexts. Decide whether to standardize on a top-level transactionBytes contract or expose a central extraction helper. Done means consumers no longer need the four-path fallback, with the chosen behavior verified across the affected tool outputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100