Turning Cross-Border E-Commerce SOPs into Agent Skills with Domain-Specific Models

    This article explains why converting cross-border e-commerce SOPs into agent skills is a contract-compilation problem rather than text rewriting. It presents a five-layer skill contract model, a nine-step generation pipeline, a routing strategy that combines domain-specific and general-purpose LLMs, and an evaluation and governance path for producing verifiable, replayable, and auditable agent skills.

    1. Problem Background: SOP-to-Skill Is Not Text Rewriting

    Cross-border e-commerce standard operating procedures (SOPs) usually exist as documents, spreadsheets, ticket templates, and chat records. They cover role assignments, trigger conditions, operational steps, rule constraints, exception branches, and acceptance criteria. Converting such SOPs into agent-executable skills is not about having a model “polish” a document into a prompt. It is about compiling a natural-language process into an execution contract that can be validated, replayed, and audited.

    A common misconception is that the most capable general-purpose large model can directly generate high-quality skills. General models do have advantages in open-domain understanding, long-text summarization, and multilingual expression. However, skill generation faces a different set of problems: inputs and outputs must satisfy structural constraints, tool calls must use correct parameters, exception branches must be covered, permission and compliance policies must be injected in advance, and generated results must enter regression testing. In other words, a skill is not “a response.” It is “a runnable, governable software asset.”

    A more reasonable approach is therefore to let domain-specific models optimized for agent skill workflows handle high-frequency, structured, strongly constrained skill generation and repair; let general-purpose models handle long-tail explanation, cross-domain knowledge supplementation, and draft generation; and route all outputs through schema validation, policy validation, and simulation replay. Model selection should not rely only on leaderboards. It should consider structural legality rate, tool-call correctness rate, exception coverage rate, and manual rework rate throughout the skill lifecycle.

    2. Skill Modeling: Breaking SOPs into Five Contract Layers

    The first step in SOP-to-skill conversion is to establish a stable skill contract. At minimum, the contract should be divided into five layers:

    1. Intent and boundary layer: Define what the skill solves and what it does not solve. For example, “review cross-border order refund requests” and “execute refund payouts” should be separate skills: the former performs rule-based judgment, while the latter performs a funds operation.
    2. Input and output layer: Define fields, types, required items, and enumeration values. Common fields in cross-border scenarios include order ID, destination country, category, logistics status, refund reason code, and evidence list.
    3. Tool and parameter layer: List the tools the skill can call and their parameter mappings, such as querying orders, validating refund policies, creating return orders, notifying warehouses, and submitting refunds. The tool list must be explicitly declared to prevent the model from improvising.
    4. State machine and exception layer: Convert “if … then …” statements in the SOP into state transitions and exception codes. Exception codes must drive subsequent actions, such as routing timeouts to manual review, requesting additional evidence when evidence is missing, and freezing and escalating disputes.
    5. Policy and audit layer: Inject permissions, compliance, approval, and traceability requirements. Audit fields should at least record the policy version, tool inputs and outputs, model version, manual operations, and final result.

    Take cross-border refund review as an example. The skill configuration can be abstracted as follows:

    1. skill: cross_border_refund_review
    2. version: 1.0.0
    3. intent: Review cross-border order refund requests
    4. inputs: order_id, reason_code, evidence_list
    5. preconditions: order exists; refund window has not expired; no active dispute
    6. tools: query_order, check_refund_policy, create_return_order, notify_warehouse, submit_refund
    7. steps:
    8. 1 Query order and logistics status
    9. 2 Match refund policy by destination country/category/time window
    10. 3 Validate evidence completeness
    11. 4 Create return order and notify warehouse
    12. 5 Submit refund when conditions are met
    13. exceptions:
    14. E_TIMEOUT: route to manual review
    15. E_EVIDENCE_MISSING: request additional evidence
    16. E_DISPUTE: freeze and escalate
    17. audit: record policy version, tool inputs and outputs, manual operations

    The benefit of this contract-based expression is that model generation has a clear target, static validation has a clear basis, and subsequent regression tests can cover fields and branches item by item.

    3. Generation Pipeline: From Documents to Runnable Skills

    SOP-to-skill conversion should be implemented as a pipeline rather than a one-off prompt call. The pipeline can include nine steps:

    1. Parse and normalize: Extract titles, roles, trigger conditions, steps, rules, exceptions, and acceptance criteria, and unify terminology and field naming.
    2. Intent extraction: Determine whether one SOP should become one skill or multiple skills, avoiding vague boundaries caused by an overly broad “all-in-one” skill.
    3. Contract generation: Generate input and output schemas, preconditions, tool lists, state machines, exception codes, and audit fields.
    4. Tool binding: Map actions in the SOP to existing tools, completing parameter sources and failure handling.
    5. Policy injection: Write permissions, compliance, approval, limits, and other rules into the skill in advance instead of leaving them for runtime ad hoc judgment.
    6. Sample synthesis: Generate test samples for positive cases, negative cases, and edge cases for subsequent validation and regression.
    7. Static validation: Check field completeness, enumeration validity, tool existence, exception coverage, and circular dependencies.
    8. Simulation replay: Replay skill execution paths using historical tickets or a simulated environment, and observe tool calls and exception branches.
    9. Human review and release: Have business experts review rules and exception handling, then move the skill into the skill library and perform canary release after approval.

    The pseudocode can be abstracted as follows:

    1. function compile_sop_to_skill(sop_document, field_registry, policy_engine):
    2. normalize_document -> extract roles/triggers/steps/rules/exceptions/acceptance
    3. infer skill intent and boundaries
    4. generate_skill_contract(input_output_schema, preconditions, tool_list, state_machine, exception_codes, audit_fields)
    5. bind_tools_and_parameter_mappings()
    6. inject_compliance_permission_approval_policies()
    7. synthesize_positive_negative_examples_and_run_static_validation()
    8. output_skill_package_and_regression_cases()

    The key value of the pipeline is turning “model generation” into “verifiable generation.” Domain-specific models can be specially optimized for normalization, contract generation, and exception completion, while general-purpose models can be used to explain complex clauses or supplement multilingual descriptions. Ultimately, however, all outputs must pass through the same validation and replay process.

    4. Model Selection: General-Purpose and Domain-Specific Models Are Not Mutually Exclusive

    Regarding whether skill development must use the top general-purpose model, the safer conclusion is: do not mythologize model capability, and do not select models solely by leaderboard. Top general-purpose models have advantages in open-ended understanding and long-tail knowledge, but skill generation depends more on structural constraints, tool calls, exception coverage, and terminology consistency. Domain-specific models optimized for skill workflows are often better at stably producing validatable results if their training covers patterns such as skill contracts, tool calls, exception branches, and audit fields.

    In practice, a routing strategy is recommended:

    • High-frequency core skills: Use domain-specific models to generate contracts, complete exceptions, and repair validation errors, with emphasis on stability and controllable cost.
    • Long-tail explanation and cross-domain knowledge: Use general-purpose models for clause explanation, multilingual descriptions, and draft generation.
    • High-risk actions: Regardless of which model generates the output, the result must pass through the policy engine, manual approval, and simulation replay.
    • Unified fallback: All outputs must pass through schema validation, tool whitelisting, permission validation, and audit traceability.

    Evaluation should not focus only on whether an answer “looks right.” Instead, build a skill quality matrix: structural legality rate, tool selection correctness rate, parameter mapping accuracy rate, exception coverage rate, manual rework rate, regression pass rate, audit completeness rate, latency, and cost. Only when these metrics are included in release gates does model selection have engineering significance.

    5. Evaluation, Governance, and Implementation Path

    After a skill goes live, it needs versioned governance. Each skill should have a semantic version, change log, regression test suite, and canary strategy. At runtime, it should collect tool-call logs, exception distribution, human intervention rate, and failure reasons. When an SOP changes, update the regression set first, then regenerate or repair the skill, and finally perform canary validation.

    At the deployment layer, generic cloud capabilities can support the pipeline. On Baidu AI Cloud, object storage can store SOP documents, samples, and skill packages; logging and monitoring services can collect runtime metrics; and a container platform can host generation, validation, and replay services. These capabilities should be used as general infrastructure to avoid tight coupling with specific interfaces.

    For implementation, start with a small set of high-frequency SOPs, such as refund review, logistics exception handling, and listing information validation. Establish skill contract templates and regression sets first, then expand gradually. The conclusion is that converting cross-border e-commerce SOPs into agent skills depends less on “which strongest model to use” and more on “the division of labor between domain-specific and general-purpose models, combined with contract-based modeling, pipeline validation, and a governance loop.” This is how to balance quality, cost, and controllability.