跳转到主要内容
Chinese, Simplified

category

正文

Putting an agent loop inside Perl 5.20+ is an engineering choice, not a performance stunt.

The runtime is already used in operations, telecom, finance, bioinformatics, and internal tooling. The script holds credentials, paths, retry logic, exception rules, and operational knowledge. Rewriting it in Python is not syntax cleanup; it is a migration.

PRAXO-CORE keeps the runtime and embeds a governed loop. This article covers the entry point, the modules, the tool boundary, the partial surfaces, and when not to use it.

Entry point

use Praxo::Agent ();
my $options = Praxo::Agent::AgentOptions->new($model);
my $result = Praxo::Agent::run_agent(
    $options, Praxo::Models::session(id => 'demo'), 'hello');
print $result->{output};

The entry point carries options, a session, a prompt, and caller-owned state. The application supplies model callbacks, tool dispatch, policy, and events. The loop owns ordering and contract checks; it does not own the business policy content.

Modules and packages

Surface Purpose
Praxo::Agent loop, options, tool registry, function tools
Praxo::Models messages, sessions, events, decisions, stream kinds
Praxo::Runtime paths, memory, checkpoint allowlist, context budget, event sinks
Praxo::Toolcall tool-call parsing and markup removal
Praxo::JsonSchema schema validation
Praxo::Plugin manifest parsing
Praxo::Middleware call limits, fallback, PII redaction, structured output

The design follows the language rather than importing a foreign object model. The goal is a small, auditable surface that fits the runtime’s existing idioms.

Tools and callbacks

A tool registration is not just a function pointer. The boundary has to define how arguments are parsed, how the policy sees final arguments, how results and failures propagate, and how events and checkpoints record what happened.

The implementation supports the tool-call formats recorded by the language README. Different models and provider prompts produce different shapes; the runtime should not assume one.

Dependencies

Perl core modules only: JSON::PP, File::Spec, and Cwd. No Python host, no provider SDK, no compiled extension for the core loop.

This is not “zero dependencies in the abstract.” It is a deliberately small dependency surface that an operator can audit.

Partial surfaces

  • Event sink covers the common path, not every optional Go hook.
  • Stream kinds are represented, but this is not an async runtime.
  • JSON Schema covers the declared vector behavior, not the full specification.

Publishing partials is part of the contract. A framework that hides them makes the integration boundary look simpler than it is.

Cost and scope

  • Event sink, stream part, and JSON Schema remain partial.
  • No async runtime.
  • No hosted provider runtime; adapters require caller transports.
  • Not general PII compliance.

The current scope also does not claim full Go parity. Check the parity inventory before depending on an optional surface.

When not to use

  • You need a hosted service, vector database, or complete graph orchestration.
  • You need an async high-throughput runtime.
  • You cannot accept a small, audited core-module dependency surface.

If one of these applies, a bridge, sidecar, migration, or a different runtime may be the better answer. That is a boundary mismatch, not a failure.

Conclusion

The value of a native Perl loop is not that it makes the language fashionable. It is that the governance boundary can stay close to the work, with an explicit scope and explicit failure modes.

Repo: https://github.com/axisvela/praxo-core
Language source: https://axisvela.github.io/praxo-core/languages/perl/
Matrix: https://github.com/axisvela/praxo-core/blob/main/spec/languages.md
Canonical: https://architect.pub/perl-glue-layer-agent-deep-dive

本文地址
最后修改
星期六, 十一月 21, 2026 - 18:18
Article
↑